��用create table语句定义SQL关系:
create table r (A1
D1 [null | not null],
��������A2 D2
[null | not null],
��������……,
��������An Dn
[null | not null],
��������<integrity-constraint1>, ……, <integrity-constraintk>)
允许的完整性约束可以是primary key (Aj1,…,Ajm)和check(P)等等,在这里指定为关系主码的属性必须非空且唯一。例如:
create table branch
������(branch-name �char(15) not null,
������branch-city � varchar(30),
������assets ����int,
������primary key �(branch-name),
������check (assets >= 0))
当然check约束还可以是其他形式,例如:
check (branch-name in (select branch-name from branch))
这一点我们还会在第五章"完整性约束与关系数据库设计"的5.1节讲述。需要注意的是: |
|