oracle中同义词的使用和授权ddl语句
如果在用户a用户下创建了一个表tab_a , 在用户b用户下使用表tab_a ,需要授权和创建同义词,
在a用户下执行
GRANT DELETE, INSERT, SELECT, UPDATE ON tab_a TO b;
在b用户下执行
CREATE SYNONYM tab_a FOR a.tab_a ;
ORA-00980 同义词已经存在或者失效
查询已经失效的同义词 删除或者重建都可以
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
1
FROM
dba_objects o
WHERE
s.table_owner = o.owner
AND s.table_name = o.object_name) ;