Oracle 建表

 1 -- Create table
 2 create table STUDENT
 3 (
 4   sno       VARCHAR2(3) not null,
 5   sname     VARCHAR2(8) not null,
 6   ssex      VARCHAR2(3) not null,
 7   sbirthday DATE,
 8   class     VARCHAR2(5)
 9 )
10 tablespace TEST.DBF
11   pctfree 10
12   initrans 1
13   maxtrans 255
14   storage
15   (
16     initial 64K
17     next 1M
18     minextents 1
19     maxextents unlimited
20   );
21 -- Add comments to the table 
22 comment on table STUDENT
23   is '学生表';
24 -- Add comments to the columns 
25 comment on column STUDENT.sno
26   is '学号(主键)';
27 comment on column STUDENT.sname
28   is '学生姓名';
29 comment on column STUDENT.ssex
30   is '学生性别';
31 comment on column STUDENT.sbirthday
32   is '学生出生年月';
33 comment on column STUDENT.class
34   is '学生所在班级';

添加数据:

课程表:

 1 -- Create table
 2 create table COURSE
 3 (
 4   cno   VARCHAR2(5) not null,
 5   cname VARCHAR2(20) not null,
 6   tno   VARCHAR2(3) not null
 7 )
 8 tablespace TEST.DBF
 9   pctfree 10
10   initrans 1
11   maxtrans 255
12   storage
13   (
14     initial 64K
15     next 1M
16     minextents 1
17     maxextents unlimited
18   );
19 -- Add comments to the table 
20 comment on table COURSE
21   is '课程表';
22 -- Add comments to the columns 
23 comment on column COURSE.cno
24   is '课程号(主键)';
25 comment on column COURSE.cname
26   is '课程名称';
27 comment on column COURSE.tno
28   is '教工编号(外键)';

添加数据:

成绩表:

 1 -- Create table
 2 create table SCORE
 3 (
 4   sno    VARCHAR2(3) not null,
 5   cno    VARCHAR2(5) not null,
 6   degree NUMBER(4,1) not null
 7 )
 8 tablespace TEST.DBF
 9   pctfree 10
10   initrans 1
11   maxtrans 255
12   storage
13   (
14     initial 64K
15     next 1M
16     minextents 1
17     maxextents unlimited
18   );
19 -- Add comments to the table 
20 comment on table SCORE
21   is '成绩表';
22 -- Add comments to the columns 
23 comment on column SCORE.sno
24   is '学号(外键)';
25 comment on column SCORE.cno
26   is '课程号(外键)';
27 comment on column SCORE.degree
28   is '成绩';

添加数据:

教师表:

 1 -- Create table
 2 create table TEACHER
 3 (
 4   tno       VARCHAR2(3) not null,
 5   tname     VARCHAR2(10) not null,
 6   tsex      VARCHAR2(3) not null,
 7   tbirthday DATE,
 8   prof      VARCHAR2(9),
 9   depart    VARCHAR2(20) not null
10 )
11 tablespace TEST.DBF
12   pctfree 10
13   initrans 1
14   maxtrans 255
15   storage
16   (
17     initial 64K
18     next 1M
19     minextents 1
20     maxextents unlimited
21   );
22 -- Add comments to the table 
23 comment on table TEACHER
24   is '教师表';
25 -- Add comments to the columns 
26 comment on column TEACHER.tno
27   is '教工编号(主键)';
28 comment on column TEACHER.tname
29   is '教工姓名';
30 comment on column TEACHER.tsex
31   is '教工性别';
32 comment on column TEACHER.tbirthday
33   is '教工出生年月';
34 comment on column TEACHER.prof
35   is '职称';
36 comment on column TEACHER.depart
37   is '教工所在部门';

添加数据:

posted @ 2016-06-08 08:38  唐枫  阅读(316)  评论(0编辑  收藏  举报