简体   繁体   中英

How to show the schema of a table include the constraints in Oracle?

describe table_name

没有显示约束,有没有办法做到这一点?

使用DBMS_METADATA包,如此处所述

You can use system views. Eg user_* or all_tab_columns and all_cons_columns. Try like this:

SELECT tc.column_id, tc.table_name, tc.column_name, tc.data_type, cc.constraint_name 
  FROM user_tab_columns tc,
       user_cons_columns cc
WHERE  tc.table_name = cc.table_name(+)
  AND  tc.column_name = cc.column_name(+)
  AND  tc.table_name = 'YOU TABLE NAME THERE'
ORDER BY tc.column_id

You need to query the USER_CONS_COLUMNS view to see the table columns and it constraints.

SELECT *
FROM   user_cons_columns
WHERE  table_name = 'TABLE_NAME';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM