Oracle查看表之间的约束

----查看表约束 

表格: user_constraints 

查询外键约束条件

select ' select count(*) from '||TABLE_NAME||';'
from user_constraints a
where
a.constraint_type = 'R'
and a.r_constraint_name='PK_JG0101';

----禁用相关外键约束
select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||';'
From user_constraints A
where a.constraint_type = 'R'
and a.r_constraint_name='PK_XX0301'
and Status='ENABLED';

 

ALTER TABLE JS0101SQ DISABLE CONSTRAINT FK_JS0101SQ_XX0301;

----启用相关外键约束

ALTER TABLE JS0101SQ ENABLE CONSTRAINT FK_JS0101SQ_XX0301;

 

---查看数据库中的表名

表:user_tables 

select 'Drop table '|| TABLE_NAME||';'
from user_tables where TABLE_NAME like 'TEMP1%';

 

posted @ 2018-09-18 17:47  元墨  阅读(3918)  评论(0编辑  收藏  举报