是否可以调整以下查询?我可以不使用减号运算符来写吗?
typeof(Genes).GetFields(BindingFlags.NonPublic);
答案 0 :(得分:1)
您可以使用LEFT JOIN代替MINUS:
SELECT m.table_owner ||'.' ||m.table_name AS table_name
FROM ALL_TAB_MODIFICATIONS m
LEFT OUTER JOIN dba_objects o
ON m.table_owner = o.owner
AND m.table_name = o.object_name
AND o.created >= sysdate -80
AND o.object_type = 'TABLE'
WHERE TIMESTAMP >= sysdate -80
AND m.table_owner IN ('AXIOM_DATA','AXIOM_DATA2','AXIOM_META','AXIOM_META2')
AND m.table_name LIKE 'RPTD_%'
AND o.table_name IS NULL
连接的右部分必须为空
答案 1 :(得分:1)
您可以尝试将其转换为NOT EXISTS
查询。如果不需要created >= SYSDATE - 80
,则可以查询较小的表dba_tables
而不是dba_objects,这意味着查询可以写为
SELECT table_owner || '.' || table_name AS table_name
FROM all_tab_modifications m
WHERE timestamp >= SYSDATE - 80 AND table_owner IN (
'AXIOM_DATA',
'AXIOM_DATA2',
'AXIOM_META',
'AXIOM_META2'
) AND table_name LIKE 'RPTD_%' AND NOT EXISTS (
SELECT 1
FROM dba_tables t
WHERE t.owner = m.table_owner AND t.table_name = m.table_name
);
但是,如果您仍然希望进行比较,则必须在NOT EXISTS
中与dba_objects
一起适当使用条件
SELECT table_owner || '.' || table_name AS table_name
FROM all_tab_modifications m
WHERE timestamp >= SYSDATE - 80 AND table_owner IN (
'AXIOM_DATA',
'AXIOM_DATA2',
'AXIOM_META',
'AXIOM_META2'
) AND table_name LIKE 'RPTD_%' AND NOT EXISTS (
SELECT 1
FROM dba_objects t
WHERE t.owner = m.table_owner AND t.object_name = m.table_name
AND t.object_type ='TABLE'
AND t.created >= SYSDATE - 80
);
答案 2 :(得分:1)
我没有Oracle数据库可以检查索引或解释计划,但是...
SELECT owner || '.' || object_name AS table_name
FROM dba_objects
WHERE created >= SYSDATE - 80 AND owner IN (
'AXIOM_DATA',
'AXIOM_DATA2',
'AXIOM_META',
'AXIOM_META2'
) AND object_name LIKE 'RPTD_%'
AND object_type != 'TABLE'