-- Create table
create table COURSE
(
cno VARCHAR2(10) not null, 列名 数据类型 是否可为空
cname VARCHAR2(20) not null, 列名 数据类型 是否可为空
tno VARCHAR2(6) not null 列名 数据类型 是否可为空
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the columns 添加注释
comment on column COURSE.cno 在cno列中添加注释
is '课程号(主键)'; 注释为 ‘XXX’
comment on column COURSE.cname
is '课程名称';
comment on column COURSE.tno
is '教工编号(外键)';
-- Create/Recreate primary, unique and foreign key constraints
alter table COURSE
add constraint C_COUNRSE primary key (CNO) 添加cno为主键
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
alter table COURSE
add constraint C_TNO foreign key (TNO) 添加 tno 为外键
references TEACHER (TNO); 外键关联 teacher 表中的 tno