如果未在“插入”语句中使用,则以下查询可以正常工作。使用“插入”语句,我收到错误“basis.sql_text:indvalid identifier”。我似乎无法弄清楚为什么。想法?
with basis as
(SELECT DISTINCT
b.snap_id,
c.begin_interval_time,
c.end_interval_time,
a.sql_id,
b.executions_delta,
DECODE (d.command_type,
1, 'Create_Table',
2, 'Insert',
3, 'Select',
6, 'Update',
7, 'Delete',
26, 'Lock Table',
35, 'Alter Database',
42, 'Alter Session',
44, 'Commit',
45, 'Rollback',
46, 'Savepoint',
47, 'Begin/Declare',
command_type) command_type,
object_owner,
NVL2 (e.index_name, e.table_name, object_name) table_name,
object_type,
DBMS_LOB.SUBSTR (d.sql_text, 256, 1) sql_text,
'DEVSDB1',
'20-JUL-12 03.55.21.000000 PM'
FROM dba_hist_sql_plan@DEVSDB1 A,
dba_hist_sqlstat@DEVSDB1 b,
dba_hist_snapshot@DEVSDB1 C,
dba_hist_sqltext@DEVSDB1 d,
dba_indexes@DEVSDB1 E
WHERE a.sql_id = b.sql_id
AND b.sql_id = d.sql_id
AND b.snap_id = c.snap_id
AND e.index_name(+) = a.object_name
AND object_owner IN ('EG', 'WV90')
AND object_type IS NOT NULL
AND end_interval_time >= (SYSDATE - 1))
INSERT INTO sdhoste.EMSDB_USAGE@DEVSDB1
SELECT basis.snap_id,
basis.begin_interval_time,
basis.end_interval_time,
basis.sql_id,
NVL (basis.executions_delta, '0'),
basis.command_type,
basis.object_owner,
t.table_name,
basis.object_type,
basis.sql_text
FROM dba_tables@DEVSDB1 T
LEFT JOIN
basis
ON basis.table_name = t.table_name
WHERE OWNER IN ('EG', 'WV90');