我使用以下代码进行查询分析。但是它不会在表中创建任何行,plsql_profiler_data。我读到我需要创建或更改权限才能生成数据。我的代码是一个简单的查询。为什么它不生成分析数据?
declare
x integer;
begin
x := dbms_profiler.start_profiler('1','1');
for rec in (Select la_Name from vv where id BETWEEN 0 AND 999999) loop
dbms_output.put_line(rec.la_name);
end loop;
x := dbms_profiler.stop_profiler;
x := dbms_profiler.flush_data;
end ;
答案 0 :(得分:1)
尝试类似:
begin
dbms_profiler.start_profiler('Test Run 1');
for rec in (Select level as levl from dual connect by level <= 10)
loop
dbms_output.put_line(rec.levl);
end loop;
DBMS_PROFILER.FLUSH_DATA;
dbms_profiler.stop_profiler;
end ;
完成后,从元数据表中获取runid:
SELECT *
FROM plsql_profiler_runs
WHERE run_comment = 'Test Run 1'
ORDER BY runid desc;
假设runid = 42,这将显示行详细信息:
SELECT u.*, d.*
FROM plsql_profiler_units u
JOIN plsql_profiler_data d ON u.runid = d.runid
AND u.unit_number = d.unit_number
WHERE u.runid = 42
ORDER BY u.unit_number, d.line#;
顺便说一句,你发布的例子没有运行(一个问题是;在“for rec in(...)”部分之后)