數(shù)據(jù)庫實驗報道_第1頁
數(shù)據(jù)庫實驗報道_第2頁
數(shù)據(jù)庫實驗報道_第3頁
數(shù)據(jù)庫實驗報道_第4頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、本文格式為word版,下載可任意編輯數(shù)據(jù)庫實驗報道 福建工程學(xué)院計算機與信息科學(xué)系 試驗 報告 2021 2021 學(xué)年第 2 學(xué)期 任課老師: xx 老師 課程名稱 數(shù)據(jù)庫系統(tǒng)概論 班級 軟件工程0901 座號 24 姓名 xx 試驗題目 0 ms sql server 2021 數(shù)據(jù)定義語言 試驗時間 試驗開頭日期:2021.3.21 報告提交日期: 2021.3.28 試驗?zāi)康摹⒁?一、 試驗題目: ms sql server 2021 數(shù)據(jù)定義語言 二、試驗?zāi)康模?1.熟識 sql server2021 查詢分析器。 2.把握 sql 語言的 ddl 子語言,在 sql server

2、2021 環(huán)境下采納 transact-sql 實現(xiàn)表的定義、刪除與修改,把握索引的建立與刪除方法。 三、試驗要求: 1.學(xué)會使用 sql server2021 的查詢分析器,企業(yè)管理器和聯(lián)機叢書。 2.依據(jù)試驗內(nèi)容仔細寫好試驗報告,記錄的試驗用例及相關(guān)信息。 3.報告內(nèi)容:試驗內(nèi)容 1,2(1)(9),其中(9)中輸入的數(shù)據(jù)不需記錄 試驗設(shè)計內(nèi)容 1.創(chuàng)建數(shù)據(jù)庫: 1)在 sql server2021 中建立一個 studb 數(shù)據(jù)庫: 有一個數(shù)據(jù)文件:規(guī)律名為 studata,文件名為"d:dbstudat.mdf',文件初始大小為 2mb,文件的最大大小不受限制,文件的增

3、長率為 2mb; 有一個日志文件,規(guī)律名為 stulog,文件名為"d:db stulog.ldf',文件初始大小為 1mb,文件的最大大小為 10mb,文件的增長率為 10% 2.設(shè)置 studb 為當前數(shù)據(jù)庫,在 studb 數(shù)據(jù)庫中作如下操作: 設(shè)有如下關(guān)系表 s: s(class,sno, name, sex, age,),主關(guān)鍵字是 no。 其中:class 為班號,char(5) ;sno 為座號,char(2),座號不能為空;name 為姓名,char(10),假設(shè)姓名的取值唯一;sex 為性別,char(2);age 為年齡,int,表中主碼為班號+座號。寫出

4、實現(xiàn)下列功能的 sql 語句。 (1) 創(chuàng)建表 s; (2) 插入一個記錄("95031' ,25,"李明',"男',21); 再插入一個記錄("95101' ,10,"王麗',"女',20); (3) 插入"95031'班學(xué)號為 30,姓名為"鄭和'的同學(xué)記錄; (4) 對表 s,按學(xué)號升序建唯一索引(索引名為 sno); 對表 s,按年齡降序建索引(索引名為 sage); (5) 向 s 表添加"入學(xué)時間(comedate)'列,

5、其數(shù)據(jù)類型為日期型(datetime); (6) 刪除 s 表的 sage 索引; (7) 將年齡的數(shù)據(jù)類型改為 smallint; (8) 刪除 s 表; (9) 根據(jù)數(shù)據(jù)庫系統(tǒng)概論(第四版)p56 頁的同學(xué)課程數(shù)據(jù)庫創(chuàng)建 student、course 和 sc 三張表,每一張表都必需有主鍵約束,合理使用列級完整性約束和表級完整性。并輸入相關(guān)數(shù)據(jù)。 3 根據(jù)數(shù)據(jù)庫系統(tǒng)概論(第四版)p74 頁習(xí)題 5 的 spj 數(shù)據(jù)庫。創(chuàng)建 spj 數(shù)據(jù)庫,并在其中創(chuàng)建 s、p、j 和 spj 四張表。每一張表都必需有主鍵約束,合理使用列級完整性約束和表級完整性。 l sql 語句實現(xiàn)要求: - 創(chuàng)建數(shù)據(jù)庫

6、的語句 use master go if exists(select * from sysdatabases where name="studb") drop database studb go create database studb on primary ( ( name=studata, filename="c c: : db studat.mdf", 注: : 我 電腦 沒有 d d 盤 size=2 2 mb, filegrowth=2mb ) ) log on (name=stulog, filename="c c: : db s

7、tulog.ldf", size=1mb, maxsize=10mb, filegrowth=10% ) ) - 創(chuàng)建表 s s 并且插入數(shù)據(jù) use studb go create table s ( ( class char(5), sno char(2), name char(10), sex char(10) unique, age int, primary key (class,sno) ) ) go insert i nto s select "95031","25"," 李明 "," 男 "

8、,21 union select "95101","10"," 王麗 "," 女 ",20 go insert into s(class,sno,name) values("95031",30," 鄭和 "); - 創(chuàng)建索引 create unique index sno on s(sno asc) create index sage on s(age desc) go - 增加列 comdate alter table s add comda te datetime go

9、drop index s.sage alter table s alter column age smallint - 刪除表 drop table s - 創(chuàng)建表 t student 并且插入數(shù)據(jù) create table student ( ( sno char(9) primary key, sname char(20) unique, ssex char(2), sage smallint, sdept char(20) ) ) go insert into db o.student select "95001"," 李勇 "," 男

10、",20,"cs" union select "95002"," 劉晨 "," 女 ",19,"is" union select "95003"," 王敏 "," 女 ",18,"ma" union select "95004"," 張立 "," 男 ",19,"is" go - 創(chuàng)建表 e course 并且插入數(shù)據(jù) crea

11、te table course ( ( cno char(4) primary key, cname char(40), cpno char( 4), ceredit smallint, foreign key (cpno) references course(cno) ) ) go insert into dbo.course values("1"," 數(shù)據(jù)庫 ",null,4) insert into dbo.course values("2"," 數(shù)學(xué) ",null,2) insert into dbo.co

12、urse values("3"," 信息系統(tǒng) ",null,4) insert into dbo.course values("4"," 操作系統(tǒng)" " ,null,3) insert into dbo.course values("5"," 數(shù)據(jù)結(jié)構(gòu) ",null,4) insert into dbo.course values("6"," 數(shù)據(jù)處理 ",null,2) l insert into dbo.course va

13、lues("7","pascal 語言 ",null,4) update dbo.course set cpno="5" where cno="1" update dbo.course set cpno="1" where cno="3" updat e dbo.course set cpno="6" where cno="4" update dbo.course set cpno="7" where cno=&qu

14、ot;5" update dbo.course set cpno="6" where cno="7" - 創(chuàng)建表 c sc 并且插入數(shù)據(jù) create table sc ( ( sno char(9), cno char(4), grade smallint, primary key (sno,cno), foreign key (sno) refer ences student(sno), foreign key (cno) references course(cno) ) ) go insert into dbo.sc select &qu

15、ot;95001","1",92 union select "95001","2",85 union select "95001","3",88 union select "95002","2",90 union select "95002","3",80 go - 在數(shù)據(jù)庫 j spj 中創(chuàng)建表 s,p,j,spj use spj go create table s ( ( sno char(10) pr

16、imary key, sname nvarchar(20) not null, status char(10), city nvarchar(20) ) ) go create table p ( ( pno char(10) primary key, pname nvarchar(20) not null, color nvarchar(10), weight int ) ) go create table j ( ( jno char(10) primary key, jname nvarchar(20) not null, city nvarchar(20) ) ) go create table spj ( ( sno char(10), pno char(10), jno char(10), qty int , foreign key (sno) references s(sno), foreign key (pno) references p(pno), foreign key (jno) reference s j(jno) ) ) go 調(diào)試過程記錄 出錯地方: 1、 在創(chuàng)建數(shù)據(jù)庫 studb 時。路徑出錯。 修改方案: : 1、需要先把文件夾建立好才能創(chuàng)建好。 試驗結(jié)果記錄以及與預(yù)期結(jié)果比較以及分析 利

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論