我熟悉ORA-01775背后的问题:循环同义词链,但是有没有调试它的技巧,或者我只需要"创建或替换"我的方法吗?
有没有办法查询架构或其他什么来找出公共同义词的当前定义是什么?
更棒的是图形工具,但在这一点上,任何事情都会有所帮助.
事实证明,问题实际上并不是一个循环的同义词链,而是同义词指向一个不存在的视图.
在这种情况下,Oracle显然是错误的循环链.
如果您使用的是TOAD,请转到视图> Toad选项> Oracle>常规并从EXPLAIN PLAN部分中删除TOAD_PLAN_TABLE并放入PLAN_TABLE
数据字典表DBA_SYNONYMS
具有关于数据库中所有同义词的信息.所以你可以运行查询
SELECT table_owner, table_name, db_link FROM dba_synonyms WHERE owner = 'PUBLIC' AND synonym_name = <>
看看公共同义词目前指的是什么.
这个错误代码的不太直观的解决方案似乎是同义词所指向的对象的问题.
这是我用于查找指向错误对象的同义词的SQL.
SELECT S.OWNER as SYN_OWNER, S.SYNONYM_NAME as SYN_NAME, S.TABLE_OWNER as OBJ_OWNER, S.TABLE_NAME as OBJ_NAME, CASE WHEN O.OWNER is null THEN 'MISSING' ELSE O.STATUS END as OBJ_STATUS FROM DBA_SYNONYMS S LEFT JOIN DBA_OBJECTS O ON S.TABLE_OWNER = O.OWNER AND S.TABLE_NAME = O.OBJECT_NAME WHERE O.OWNER is null OR O.STATUS != 'VALID';
尝试此选择以查找有问题的同义词,它列出指向不存在的对象的所有同义词(表,视图,序列,包,过程,函数)
SELECT * FROM dba_synonyms WHERE table_owner = 'USER' AND ( NOT EXISTS ( SELECT * FROM dba_tables WHERE dba_synonyms.table_name = dba_tables.TABLE_NAME ) AND NOT EXISTS ( SELECT * FROM dba_views WHERE dba_synonyms.table_name = dba_views.VIEW_NAME ) AND NOT EXISTS ( SELECT * FROM dba_sequences WHERE dba_synonyms.table_name = dba_sequences.sequence_NAME ) AND NOT EXISTS ( SELECT * FROM dba_dependencies WHERE type IN ( 'PACKAGE' ,'PROCEDURE' ,'FUNCTION' ) AND dba_synonyms.table_name = dba_dependencies.NAME ) )