Home  >  Article  >  Database  >  Oracle中两个记录约束的系统表

Oracle中两个记录约束的系统表

WBOY
WBOYOriginal
2016-06-07 17:18:11864browse

例如,我现在要删除TBL_USER表中的某条记录,此时会报错误:ORA-02292 integrity constraint (ESAWEB.FK_TBL_USER_REFERENCE_TBL

当要查询某一个约束在哪个表中时,会用到下面两个系统表。

user_constraints约束表,记录该用户的所有约束。如非空,索引等等。

user_cons_columns约束字段表,记录每个约束涉及到的所有字段。

例如,,我现在要删除TBL_USER表中的某条记录,此时会报错误:ORA-02292 integrity constraint (ESAWEB.FK_TBL_USER_REFERENCE_TBL_USER) violated - child record found.错误,说明TBL_USER表的某一列有外键约束,此时需要找到这个外键约束的表中记录并删除。

select * from user_constraints t where t.CONSTRAINT_NAME = ' FK_TBL_USER_REFERENCE_TBL_USER ' ;

找到TABLE_NAME字段中的值,这里面的值就是存在FK_TBL_USER_REFERENCE_TBL_USER约束的表,在此表中找到相应记录并删除即可。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn