?
1、建表
create table userInfo (
id number(6),
name varchar2(20),
sex number(1),
age number(3),
birthday date,
address varchar2(50),
email varchar2(25),
tel number(11)
);
?
2、创建约束
不带约束名称的:
create table userInfo (
id number(6) primary key,--主键
name varchar2(20) not null,--非空
sex number(1),
age number(3) default 18,
birthday date,
address varchar2(50),
email varchar2(25) unique,--唯一
tel number(11),
deptno number(2) references dept(deptno)—外键
);
带约束名称:
create table userInfo (
id number(6) constraint id_pk primary key,
name varchar2(20) constraint name_nn not null,
sex number(1),
age number(3) default 18,
birthday date,
address varchar2(50),
email varchar2(25) constraint email_uqe unique,
tel number(11),
deptno number(2) constraint dept_deptno_ref references dept(deptno)
);
?
列模式:
create table userInfo (<