程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> Oracle 建表,oracle建表

Oracle 建表,oracle建表

編輯:Oracle教程

Oracle 建表,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 '教工所在部門';

添加數據:

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved