Chinaunix首页 | 论坛 | 博客
  • 博客访问: 378518
  • 博文数量: 113
  • 博客积分: 3035
  • 博客等级: 中校
  • 技术积分: 1430
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-01 16:32
文章分类
文章存档

2011年(42)

2010年(70)

2009年(1)

我的朋友

分类: Oracle

2010-04-26 15:00:35

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)

阅读(747) | 评论(0) | 转发(0) |
0

上一篇:(转)oracle hint

下一篇:create table

给主人留下些什么吧!~~