How can I find the OWNER of an object in Oracle?

后端 未结 5 1176
攒了一身酷
攒了一身酷 2021-01-31 19:59

I want to find the foreign keys of a table but there may be more than one user / schema with a table with the same name. How can I find the one that the currently logged user is

5条回答
  •  忘掉有多难
    2021-01-31 20:19

    Interesting question - I don't think there's any Oracle function that does this (almost like a "which" command in Unix), but you can get the resolution order for the name by:

    select * from 
    (
     select  object_name objname, object_type, 'my object' details, 1 resolveOrder 
      from user_objects
      where object_type not like 'SYNONYM'
     union all
     select synonym_name obj , 'my synonym', table_owner||'.'||table_name, 2 resolveOrder
      from user_synonyms
     union all
     select  synonym_name obj , 'public synonym', table_owner||'.'||table_name, 3 resolveOrder
      from all_synonyms where owner = 'PUBLIC'
    )
    where objname like upper('&objOfInterest')
    

提交回复
热议问题