top of page
Search

Query to know the Primary keys of all tables in a Schema in Oracle Database

How query all primary keys of all tables owned by a schema_name - Just replace 'P' with 'F' to know foreign key


select
   all_cons_columns.owner as schema_name,
   all_cons_columns.table_name,  
   all_cons_columns.column_name, 
   all_cons_columns.position, 
   all_constraints.status,
   all_constraints.constraint_name
from all_constraints, all_cons_columns 
where 
   all_constraints.constraint_type = 'F'
   and all_constraints.constraint_name = all_cons_columns.constraint_name
   and all_constraints.owner = all_cons_columns.owner
   and all_cons_columns.owner = '&User_name'
  order by 
   all_cons_columns.owner,
   all_cons_columns.table_name, 
   all_cons_columns.position;
17 views0 comments

Recent Posts

See All

Comments


Contact Me

Tel: 7989359581

Lakshminarayana0071@gmail.com

  • Facebook Social Icon
  • LinkedIn Social Icon
  • Twitter Social Icon

Thanks for submitting!

© 2023 by Phil Steer . Proudly created with Wix.com

bottom of page