[Oracle]列出所有的PK&UK

摘要:[Oracle]列出所有的PK&UK

select 
  C.TABLE_NAME, D.POSITION, D.COLUMN_NAME  ,C.INDEX_NAME,c.CONSTRAINT_TYPE
FROM 
  ALL_CONSTRAINTS C JOIN ALL_CONS_COLUMNS D
ON
  C.OWNER = D.OWNER AND
  c.constraint_name = d.constraint_name
where
d.owner ='WMS_OWNER' AND
  (c.constraint_type = 'P'or c.constraint_type = 'U' )
order by c.table_name, d.position,d.column_name,c.index_name;
/