1. 查看sql执行计划(explain,非真实执行,绑定变更可赋值也可不赋值):
set timing on;
set line 300 pagesize 3000;
alter session set statistics_level = 'ALL';
explain plan for select * from table1 where id=2;
select * from table(dbms_xplan.display());
2. 查看sql执行计划(真实执行后生成,对于非select语句需谨慎使用):(生成SQL_ID)
set timing on;
set line 300 pagesize 3000;
alter session set statistics_level = 'ALL';
select * from table1 where id=2;
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST ADVANCED PEEKED_BINDS'));