1 语法
1.1 行级定义
1.2 表级定义
2 NOT NULL
只能行级定义.
SQL> create table tn0(a number(4) not null, b varchar2(20));
SQL> create table tn1(a number(4) constraint nn_tn1_a not null, b varchar2(20));
3 Unique
SQL> create table tu0(a number(4) unique, b varchar2(20));
SQL> create table tu1(a number(4) constraint u_tu1_a unique, b varchar2(20));
SQL> create table tu2(a number(4), b varchar2(20), constraint u_tu2_a unique(a));
SQL> create table tu3(a number(4), b varchar2(20), constraint u_tu3_a unique(a, b));
4 主键
SQL> create table t0(a number(4) primary key, b varchar2(20));
SQL> create table t1(a number(4), b varchar2(20), primary key(a));
SQL> create table t2(a number(4) constraint pk_t2 primary key, b varchar2(20));
SQL> create table t3(a number(4), b varchar2(20), constraint pk_t3 primary key(a));
SQL> create table t4(a number(4), b varchar2(20), constraint pk_t4 primary key(a, b));
5 外键
SQL> create table tf_p(a number(4) primary key, b varchar2(20));
SQL> insert into tf_p values(1, 'aa');
SQL> insert into tf_p values(2, 'bb');
SQL> insert into tf_p values(3, 'cc');
SQL> create table tf_s(a number(4) constraint fk_tf_sa_ref_tf_pa references tf_p , c varchar2(20));