Home > Database > Mysql Tutorial > Oracle 获取外键

Oracle 获取外键

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:27:44
Original
1052 people have browsed it

Oracle获取外键将会使用到一张系统表:user_constraints。所有有时间在Oracle需要手动处理数据,在删除一张主表时,要先把引用主

Oracle获取外键将会使用到一张系统表:user_constraints。
 
如获取全部外键:
 
select CONSTRAINT_NAME 约束名称,TABLE_NAME 表
from user_constraints t where
1=1
 --t.table_name in('TBL_STEP')
 and CONSTRAINT_TYPE ='R' 
 AND CONSTRAINT_NAME='FK_STEP_ID';
 
所有有时间在Oracle需要手动处理数据,在删除一张主表时,要先把引用主表记录的次表记录删除;删除主表记录时,往往会报FK制约引用的错误。
 
上面会有外键名称。通过下面语句我们就能找到所属从表了,再做处理。
 
select CONSTRAINT_NAME 约束名称,TABLE_NAME 表
from user_constraints t where
1=1
 t.table_name in('TBL_STEP')
 and CONSTRAINT_TYPE ='R' 
 AND CONSTRAINT_NAME='FK_STEP_ID';

linux

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template