我需要在ORACLE中获取SYNONYMS的列表。创建同义词的表位于其他模式中。任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
什么时候回复都不晚
select * from all_tab_columns@&SYNONYM_DB_LINK
where upper(table_name) like '&TARGET_TABLE_NAME'
order by owner, table_name, column_id
答案 1 :(得分:0)
在OWNER中是同义词所有者
select * from all_synonyms
where table_owner=upper(:table_owner) and table_name=upper(:table_name)
“列列表”中的含义是什么?
答案 2 :(得分:0)
这将返回数据库中所有同义词的列表:
select * from DBA_SYNONYMS
order by synonym_name
这将返回带有“ like”名称的同义词列表:
select * from DBA_SYNONYMS
where upper(synonym_name) like upper('%SYNONYM_NAME_HERE%')
order by synonym_name
响应中的相关列名称:
SYNONYM_NAME
TABLE_NAME
答案 3 :(得分:0)
这是我用来查看同义词及其目标的查询。
您将需要在SELECT
和DBA_SYNONYMS
上拥有DBA_OBJECTS
特权。
select decode(owner, 'PUBLIC', 'PUBLIC SYNONYM', 'SYNONYM') as objtype,
decode(owner, 'PUBLIC', '', owner) as objowner,
synonym_name as objname,
synonym_name || ' => ' ||
case
when db_link is null then '(' || (
select o1.object_type from dba_objects o1 where o1.owner = table_owner and o1.object_name = table_name and o1.object_type in ('VIEW','TABLE','SYNONYM','SEQUENCE','FUNCTION','PROCEDURE','PACKAGE','MATERIALIZED VIEW','JAVA CLASS','TYPE')
and not exists (select 1 from dba_objects o2 where o2.owner = o1.owner and o2.object_name = o1.object_name and o1.object_type = 'TABLE' and o2.object_type = 'MATERIALIZED VIEW')
) || ') ' || table_owner || '.' || table_name
else decode(table_owner, null, '', table_owner || '.') || table_name || decode(db_link, null, '', '@' || db_link)
end as objdesc
from dba_synonyms
where OWNER != 'PUBLIC'
order by 1,2,3,4
有点罗word,但它的输出很好,像这样:
OBJTYPE OBJOWNER OBJNAME OBJDESC
------- ----------- -------------------- -----------------------------------------------------------------------------
SYNONYM SYSTEM PRODUCT_USER_PROFILE PRODUCT_USER_PROFILE => (TABLE) SYSTEM.SQLPLUS_PRODUCT_PROFILE
SYNONYM SYSTEM TAB TAB => (VIEW) SYS.TAB
这实际上是我用于查找各种类型的对象的较大查询的一部分,因此还包含一些冗余信息。
我过滤掉了PUBLIC
,因为那是一个巨大的清单。
答案 4 :(得分:0)
select * from all_tab_cols where table_name in
(select TABLE_NAME from all_synonyms where owner = <SCHEMA_NAME> )