0%

ORA-00980同义词转换不再有效

问题:
ORA-00980: 同义词转换不再有效

解决方法:
使用拥有dba权限的账号sys的登录。
执行查找所有失效的同义词,生成删除脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--复制需要删除的同义词
select 'drop '
|| decode(s.owner,
'PUBLIC',
'public synonym ',
'synonym ' || s.owner || '.')
|| s.synonym_name
|| ';' as "Dropping invalid synonyms:"
from dba_synonyms s
where table_owner not in ('SYSTEM', 'SYS')
and db_link is null
and not exists
(select null
from dba_objects o
where s.table_owner = o.owner
and s.table_name = o.object_name);

处理办法删除重建:
SQL>Drop public synonym T_INVEST_ZS;
SQL>Create public synonym T_INVEST_ZS; for 用户名.T_INVEST_ZS;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--复制需要创建的同义词
select 'create '
|| decode(s.owner,
'PUBLIC',
'public synonym ',
'synonym '
|| s.owner || '.')
|| s.synonym_name
|| ' for'
|| ' 用户名'
|| '.'
|| s.synonym_name
|| ';' as "Dropping invalid synonyms:"
from dba_synonyms s
where table_owner not in ('SYSTEM', 'SYS')
and db_link is null
and not exists
(select null
from dba_objects o
where s.table_owner = o.owner
and s.table_name = o.object_name);