Oracle 查看一个表对应的主键和外键的约束关系,查看的语句:
select a.owner, --主键拥有者
a.table_name, --主键表
b.column_name, --主键列
c.OWNER, --外键拥有者
c.table_name, --外键表
d.column_name --外键列
from user_constraints a
left join user_cons_columns b
on a.constraint_name=b.constraint_name
left join user_constraints c
on c.R_CONSTRAINT_NAME=a.constraint_name
left join user_cons_columns d
on c.constraint_name=d.constraint_name
where a.constraint_type='P'
and a.table_name='xxx' --需要查看主外键关系的表
order by a.table_name
数据字典表列说明:
desc user_constraints
Name Comments
OWNER 表的所有者
CONSTRAINT_NAME 约束名
CONSTRAINT_TYPE 约束类型
TABLE_NAME Name associated with table with constraint definition
SEARCH_CONDITION Text of search condition for table check
R_OWNER Owner of table used in referential constraint
R_CONSTRAINT_NAME Name of unique constraint definition for referenced table
DELETE_RULE The delete rule for a referential constraint
STATUS Enforcement status of constraint - ENABLED or DISABLED
DEFERRABLE Is the constraint deferrable - DEFERRABLE or NOT DEFERRABLE
DEFERRED Is the constraint deferred by default - DEFERRED or IMMEDIATE
VALIDATED Was this constraint system validated? - VALIDATED or NOT VALIDATED
GENERATED Was the constraint name system generated? - GENERATED NAME or USERNAME
BAD Creating this constraint should give ORA-02436. Rewrite it before2000 AD.
RELY If set, this flag will be used in optimizer
LAST_CHANGE The date when this column was last enabled or disabled
INDEX_OWNER The owner of the index used by the constraint
INDEX_NAME The index used by the constraint
INVALID
VIEW_RELATED
desc user_cons_columns;
Name Default Comments
OWNER Owner of the constraint definition
CONSTRAINT_NAME Name associated with the constraint definition
TABLE_NAME Name associated with table with constraint definition
COLUMN_NAME Name associated with column or attribute of object column specified in the constraint definition
POSITION Original position of column or attribute in definition
分享到:
相关推荐
DBA_CONS_COLUMNS、ALL_CONS_COLUMNS和USER_CONS_COLUMNS显示有关列的相关约束的一般信息。 视图 DBA_VIEWS、ALL_VIEWS和USER_VIEWS。 注意:DBA_OBJECTS、ALL_OBJECTS和USER_OBJECTS显示了模式对象的信息,包括...
DC综合系统学习
from all_constraints, all_cons_columns where all_cons_columns.CONSTRAINT_NAME = all_constraints.CONSTRAINT_NAME and all_constraints.CONSTRAINT_TYPE = 'P' and all_constraints.OWNER = '用户名') C ...
Predictive_Control_with_Constraints
Gearbox_Design_for_tight_Space_Constraints_with_simultaneous_Cost__Estimation
from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P') tab_pk on all_c.table_name = tab_pk.pk_tab_name and all_c.column_name =...
robust optimization_sliders_stanford_univ_chance_constraints.pdf
Select constraint_name,table_name, constraint_type from user_constraints; 其中constraint_type取值的含义如下: C——check P——primary key U——unique R——referential O——view with read only ...
详细介绍xilinx设计中的利用vivado进行引脚约束以及时序约束
在转移数据库,进行数据导入的时候,遇到一件麻烦事,就是表间外键约束的存在,导致insert频频报错,批量执行sql语句又是顺序执行,没办法我只好手动输入。...' from user_constraints where constraint_ty
将 spree_order_constraints 添加到您的 Gemfile 中: gem 'spree_order_constraints' 捆绑您的依赖项并运行安装生成器: bundle ./bin/rails g spree_order_constraints:install 测试 首先捆绑您的依赖项,然后...
详细介绍FPGA的时序逻辑设计,简要介绍时序设置需要注意的要点与重点,set up time and hold time and so on
from user_constraints c,user_cons_columns cc where c.owner = upper(\'&table_owner\') and c.table_name = upper(\'&table_name\') and c.owner = cc.owner and c.constraint_name = cc.constraint_name ...
require "type_constraints" TypeConstraints . setup do type :Array do constraint -> v { v . kind_of? ( Array ) } end subtype :ArrayOfString , :Array do constraint -> v { v . all? ( ) { | v | v . ...
from user_constraints c,user_cons_columns cc where c.owner = upper('&table_owner') and c.table_name = upper('&table_name') and c.owner = cc.owner and c.constraint_name = cc.constraint_name order ...
from user_constraints c,user_cons_columns cc where c.owner = upper('&table_owner') and c.table_name = upper('&table_name') and c.owner = cc.owner and c.constraint_name = cc.constraint_name order ...
根据xilinx官方demo生成的ISE工程文件,包含最终生成bit文件。并插入ila核使用chipscope抓包。详细的说明文档详见我的博客:http://www.cnblogs.com/yuzeren48/
select * from user_constraints u where u.constraint_name like '%TB_ROLE%'; --失效约束 alter table TP_MENU disable constraint FK_TP_MENU_REFERENCE_TP_MENU cascade; alter table TB_ROLE_REF_MENU disable ...
xilinx Timing Constraints User Guide
Matlab集成的c代码人机协作的机械手性能约束 描述: 使用机械手的任何本地性能指标将机械手限制在某个阈值以上。 这对于避免人机交互中的奇异点特别有用 可以在以下RCIM文件中找到详细说明: Dimeas,Fotios,...