在系统易用中,经常使用synonym,以便于管理或者权限控制。
因此会经常遇到ORA-01775: 同义词的循环链
oracle的解释是这样的:
ORA-01775: looping chain of synonyms
Cause: Through a series of CREATE synonym statements, a synonym was defined that referred to itself. For example, the following definitions are circular:
CREATE SYNONYM s1 for s2 CREATE SYNONYM s2 for s3 CREATE SYNONYM s3 for s1
Action: Change one synonym definition so that it applies to a base table or view and retry the operation.
其实原因很简单:做为同义词的基础的表、存储过程、视图、函数、序列等不存在了。
看如下的例子:
SQL> create table test1(id int);
Table created
SQL> create table "test"(id int);
Table created
SQL> create public synonym test for test;
Synonym created
SQL> create public synonym test1 for test1;
Synonym created
SQL> create public synonym test2 for test2;
Synonym created
SQL> grant select,insert,delete,update on test to public;
grant select,insert,delete,update on test to public
ORA-01775: 同义词的循环链
SQL> grant select,insert,delete,update on test1 to public;
Grant succeeded
SQL> grant select,insert,delete,update on test2 to public;
grant select,insert,delete,update on test2 to public
ORA-01775: 同义词的循环链
以上两个表出现了同义词循环链,第一个表是因为建表时表名使用了双引号,而我们授权的时候一般都是查询dba_tables表,所以建立的同义词有问题;而第三个同义词是基表不存在,或者该表已经被删除。
一次出现同义词链的问题的时候,首先确认同义词的基础是否存在,如果存在的话,是不是名称有什么异常。
当然也遇见过一次诡异的同义词链问题,给存储过程建同义词的时候,一个trigger竟然跑到dba_procedures里边去了。
另外一个问题就是ORA-00942: 表或视图不存在
对于test1表已经创建同义词,换一个用户,执行如下操作:
SQL> alter table test1 modify(id number(10));
alter table test1 modify(id number(10))
ORA-00942: 表或视图不存在
SQL> select count(*) from test1;
COUNT(*)
----------
0
SQL> alter table test.test1 modify(id number(10));
alter table test.test1 modify(id number(10))
ORA-01031: 权限不足
明明是权限不足,却报表或视图不存在!
因此会经常遇到ORA-01775: 同义词的循环链
oracle的解释是这样的:
ORA-01775: looping chain of synonyms
Cause: Through a series of CREATE synonym statements, a synonym was defined that referred to itself. For example, the following definitions are circular:
CREATE SYNONYM s1 for s2 CREATE SYNONYM s2 for s3 CREATE SYNONYM s3 for s1
Action: Change one synonym definition so that it applies to a base table or view and retry the operation.
其实原因很简单:做为同义词的基础的表、存储过程、视图、函数、序列等不存在了。
看如下的例子:
SQL> create table test1(id int);
Table created
SQL> create table "test"(id int);
Table created
SQL> create public synonym test for test;
Synonym created
SQL> create public synonym test1 for test1;
Synonym created
SQL> create public synonym test2 for test2;
Synonym created
SQL> grant select,insert,delete,update on test to public;
grant select,insert,delete,update on test to public
ORA-01775: 同义词的循环链
SQL> grant select,insert,delete,update on test1 to public;
Grant succeeded
SQL> grant select,insert,delete,update on test2 to public;
grant select,insert,delete,update on test2 to public
ORA-01775: 同义词的循环链
以上两个表出现了同义词循环链,第一个表是因为建表时表名使用了双引号,而我们授权的时候一般都是查询dba_tables表,所以建立的同义词有问题;而第三个同义词是基表不存在,或者该表已经被删除。
一次出现同义词链的问题的时候,首先确认同义词的基础是否存在,如果存在的话,是不是名称有什么异常。
当然也遇见过一次诡异的同义词链问题,给存储过程建同义词的时候,一个trigger竟然跑到dba_procedures里边去了。
另外一个问题就是ORA-00942: 表或视图不存在
对于test1表已经创建同义词,换一个用户,执行如下操作:
SQL> alter table test1 modify(id number(10));
alter table test1 modify(id number(10))
ORA-00942: 表或视图不存在
SQL> select count(*) from test1;
COUNT(*)
----------
0
SQL> alter table test.test1 modify(id number(10));
alter table test.test1 modify(id number(10))
ORA-01031: 权限不足
明明是权限不足,却报表或视图不存在!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10805681/viewspace-588718/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10805681/viewspace-588718/