--复制需要删除的同义词 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;
--复制需要创建的同义词 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);