設有一數據庫,包括四個表:學生表(Student)、課程表(Course)、成績表(Score)以及教師信息表(Teacher)。四個表的結構分別如表1-1的表(一)~表(四)所示,數據如表1-2的表(一)~表(四)所示。用SQL語句創建四個表並完成相關題目。


表(一)Student (學生表) 

-- Create table
create table STUDENT
(
  sno       VARCHAR2(3) not null,
  sname     VARCHAR2(8) not null,
  ssex      VARCHAR2(2) not null,
  sbirthday DATE,
  class     VARCHAR2(5)
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255;
-- Add comments to the table 
comment on table STUDENT
  is '學生表';
-- Add comments to the columns 
comment on column STUDENT.sno
  is '學號(主鍵)';
comment on column STUDENT.sname
  is '學生姓名';
comment on column STUDENT.ssex
  is '學生性別';
comment on column STUDENT.sbirthday
  is '學生出生年月';
comment on column STUDENT.class
  is '學生所在班級';

表(一)Student中的數據

表(二)Course(課程表)

-- Create table
create table COURSE
(
  cno   VARCHAR2(5) not null,
  cname VARCHAR2(10) not null,
  tno   VARCHAR2(3) not null
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255;
-- Add comments to the table 
comment on table COURSE
  is '課程表';
-- Add comments to the columns 
comment on column COURSE.cno
  is '課程號(主鍵)';
comment on column COURSE.cname
  is '課程名稱';
comment on column COURSE.tno
  is '教工編號(外鍵)';

表(二)Course(課程表)中的數據

表(三)Score(成績表)

 

-- Create table
create table SCORE
(
  sno    VARCHAR2(3) not null,
  cno    VARCHAR2(5) not null,
  degree NUMBER(4,1)
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255;
-- Add comments to the table 
comment on table SCORE
  is '成績表';
-- Add comments to the columns 
comment on column SCORE.sno
  is '學號(外鍵)';
comment on column SCORE.cno
  is '課程號(外鍵)';
comment on column SCORE.degree
  is '成績';

表(三)Score(成績表)中的數據

表(四)Teacher(教師表)

 

-- Create table
create table TEACHER
(
  tno       VARCHAR2(3) not null,
  tname     VARCHAR2(4) not null,
  tsex      VARCHAR2(2) not null,
  tbirthday DATE,
  prof      VARCHAR2(6),
  depart    VARCHAR2(10) not null
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255;
-- Add comments to the table 
comment on table TEACHER
  is '教師表';
-- Add comments to the columns 
comment on column TEACHER.tno
  is '教工編號(主鍵)';
comment on column TEACHER.tname
  is '教工姓名';
comment on column TEACHER.tsex
  is '教工性別';
comment on column TEACHER.tbirthday
  is '教工出生年月';
comment on column TEACHER.prof
  is '職稱';
comment on column TEACHER.depart
  is '教工所在部門';

表(四)Teacher(教師表)中的數據

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM