首页 > 代码库 > 用SQL语言建表,课1

用SQL语言建表,课1

--删除表
--drop table teachers;
--创建表
create table teachers
(
tno varchar2(6) not null,
tname varchar2(8) not null,
tsex varchar2(4) not null,
tsr date,
pro varchar2(10),
depa varchar2(14)
);

--添加注释
comment on column teachers.tno
is‘ 教师编号(主键)‘;
comment on column teachers.tname
is‘ 教师名称‘;
comment on column teachers.tsex
is‘ 教师性别)‘;
comment on column teachers.tsr
is‘ 教师生日‘;
comment on column teachers.pro
is‘ 教师职称)‘;
comment on column teachers.depa
is‘ 教师部门)‘;

--添加主键约束
--alter 修改的意思
alter table teachers add constraint pk_teachers primary key(tno);

 

技术分享

 

用SQL语言建表,课1