更新时间:2023-02-04 10:53:28
需要查询数据字典,特别是USER_CONS_COLUMNS
视图查看表列和对应的约束:
You need to query the data dictionary, specifically the USER_CONS_COLUMNS
view to see the table columns and corresponding constraints:
SELECT *
FROM user_cons_columns
WHERE table_name = '<your table name>';
仅供参考,除非您专门使用小写名称(使用双引号)创建了表格,否则表格名称将默认为大写,因此请确保在您的查询中也是如此.
FYI, unless you specifically created your table with a lower case name (using double quotes) then the table name will be defaulted to upper case so ensure it is so in your query.
如果您希望查看有关约束本身的更多信息,请查询 USER_CONSTRAINTS
视图:
If you then wish to see more information about the constraint itself query the USER_CONSTRAINTS
view:
SELECT *
FROM user_constraints
WHERE table_name = '<your table name>'
AND constraint_name = '<your constraint name>';
如果表保存在不是默认架构的架构中,那么您可能需要将视图替换为:
If the table is held in a schema that is not your default schema then you might need to replace the views with:
all_cons_columns
和
all_constraints
添加到 where 子句:
adding to the where clause:
AND owner = '<schema owner of the table>'