實驗題目: 資料定義
班級: 1x級36—x班
學號: 11103060x0x
姓名***
實驗一資料定義
一、學時 2學時
二、實驗型別驗證性、設計性
三、實驗目的
利用查詢分析器用sql語言定義基本表、索引並進行相關操作。
四、實驗內容
背景材料:在以下實驗中,使用學生-課程資料庫,它描述了學生的基本資訊、課程的基本資訊及學生選修課程的資訊。
1、建立學生課程資料庫
create database student;
use student;
2、建立學生關係表s :(學號要求非空且唯一,姓名要求唯一值)
create table student
(sno char(9) primary key,
sname char(20) unique,
s*** char(2),
sage smallint,
sdept char(20)
);3、建立課程關係表c :(課程號要求非空且唯一)
create table course
(cno char(4) primary key,
cname char(40),
cpno char(4),
ccredit smallint,
foreign key (cpno) references course(cno)
);4. 建立課程關係表sc :
create table sc
(sno char(9),
cno char(4),
grade smallint,
primary key(sno,cno),
foreign key (sno) references student(sno),
foreign key (cno) references course(cno)
);5、將以上建立表s、c、sc的sql命令以 .sql檔案的形式儲存在磁碟上。
6、在表s上增加「出生日期」屬性列。
alter table student add birthday datetime;
7、刪除表s的「年齡」 屬性列。
alter table student drop column sage;
8、刪除s姓名列的唯一值約束。
alter table student drop uq__student__77bfcb91;
9、修改sc表成績屬性列為精確數字型。
alter table sc alter column grade decimal;
10、在表s上,按「sno」 屬性列的唯一值方式建立索引。
create unique index serch on student(sno);
11、刪除表sc,利用磁碟上儲存的.sql檔案重新建立表sc。
create unique index serch on student(sno);
create table sc
(sno char(9),
cno char(4),
grade smallint,
primary key(sno,cno),
foreign key (sno) references student(sno),
foreign key (cno) references course(cno)
);12、建立教材p74頁習題5中spj資料庫中的四個關係:s、p、j、spj。
create database s;
use s;
create table s
(sno char(9) primary key,
sname char(20) unique,
status char(2),
city char(20)
);create table p
(pno char(4) primary key,
pname char(40),
color char(4),
weight smallint
);create table j
(jno char(4) primary key,
jname char(40),
city char(4)
);create table spj
(sno char(9),
pno char(4),
jno char(4),
qty smallint,
primary key(sno,cno),
foreign key (sno) references s(sno),
foreign key (cno) references j(jno),
foreign key (cno) references p(pno));
資料庫原理實驗報告S9 資料庫索引
要求 1.報告格式和內容要求 a.內容和格式整齊。大標題採用黑體四號字加粗,小標題採用小四號字加粗。正文採用五號宋體,單倍行距。b.貼圖時請剪裁到適當大小,要保證列印時可以看清,但也不要太大以免 越界 c.不要在報告中寫與實驗無關的話,內容要有條理 完整 並能突出重點,要將遇到的主要問題說明。2.檔...
資料庫實驗報告
資料庫系統概論 實驗報告 實驗三 sql單錶查詢和多表查詢 一 實驗目的 1 觀察查詢結果,體會select語句實際應用 2 要求學生能夠在access環境中使用select語句進行簡單查詢 資料排序和資料連線查詢的操作方法 二 實驗準備 本實驗需要用到實驗一所建立的 學生成績管理 的資料庫和stu...
資料庫實驗報告
資料庫原理 實驗報告 東北大學秦皇島分校 4.在查詢分析器中按照下列要求修改第3題中建立的資料庫test2 1 主要資料檔案的容量為2mb,最大容量為20mb,增幅為2mb。2 次要資料檔案的容量為2mb,最大容量為20mb,增幅為2mb。事務日誌檔案的容量為1mb,最大容量為10mb,增幅為2mb...