使用场景:
在做oracle维护时,当有些环境不允许使用其它工具,如plsql developer时,而sqlplus的格式控制又比较麻烦时,我们可以使执行脚本的结构用html的形式保存起来,这样便于查看。
方法:
SQL> set markup html on |
生成的test.html如下:
SQL> SELECT STAT.SQL_ID,
2 SQL_TEXT,
3 PLAN_HASH_VALUE,
4 PARSING_SCHEMA_NAME,
5 ELAPSED_TIME_DELTA,
6 STAT.SNAP_ID,
7 SS.END_INTERVAL_TIME
8 FROM DBA_HIST_SQLSTAT STAT, DBA_HIST_SQLTEXT TXT, DBA_HIST_SNAPSHOT SS
9 WHERE STAT.SQL_ID = TXT.SQL_ID
10 AND STAT.DBID = TXT.DBID
11 AND SS.DBID = STAT.DBID
12 AND SS.INSTANCE_NUMBER = STAT.INSTANCE_NUMBER
13 AND STAT.SNAP_ID = SS.SNAP_ID
14 -- AND STAT.DBID = ?
15 AND SS.BEGIN_INTERVAL_TIME >= sysdate - 7
16 AND UPPER(SQL_TEXT) LIKE '%&v_tab%'
17 AND PARSING_SCHEMA_NAME LIKE '&v_SCHEMA_NAME%'
18 ORDER BY ELAPSED_TIME_DELTA DESC;
Enter value for v_tab: EOP_MEMO_BASIC
old 16: AND UPPER(SQL_TEXT) LIKE '%&v_tab%'
new 16: AND UPPER(SQL_TEXT) LIKE '%EOP_MEMO_BASIC%'
Enter value for v_schema_name: XJDB1
old 17: AND PARSING_SCHEMA_NAME LIKE '&v_SCHEMA_NAME%'
new 17: AND PARSING_SCHEMA_NAME LIKE 'XJDB1%'
SQL_ID | SQL_TEXT | PLAN_HASH_VALUE | PARSING_SCHEMA_NAME | ELAPSED_TIME_DELTA | SNAP_ID | END_INTERVAL_TIME |
---|---|---|---|---|---|---|
ca1zk19td8wpt | select col.*, com.Co mments from sys.all_ tab_columns col, sys.all_col_commen | 487744160 | XJDB1EXCHANGE | 72276 | 424 | 24-MAY-12 11.01.00.446 AM |
SQL> spool off
转载于:https://blog.51cto.com/mibon/912742