oracle约束一共5种
not null
primary key:相当于unique+not null,建议每个表都有主键,便于日后数据高级复制等其它操作
foreign key:建议建立索引,当子表外键列上有索引,删除主表的记录时,只会锁定子表参考主表的对应记录
unique:可以针对多列,如constaint xx unique(col1,col2)
每个null值都是唯一的,即null!=null
check:如 constraint xx check(col1>20)
主键的写法:constaint P_1 primary key(col1)
外键的写法:constraint R_1 foreign key(col) references main_table(col1)
查询约束的表
xxx_constraints
xxx_cons_columns
constraint_type
C (check constraint on a table)
P (primary key)
U (unique key)
R (referential integrity)
V (with check option, on a view)
O (with read only, on a view)
阅读(754) | 评论(0) | 转发(0) |