久久99精品久久久久久琪琪,久久人人爽人人爽人人片亞洲,熟妇人妻无码中文字幕,亚洲精品无码久久久久久久

數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦]

時間:2019-05-13 17:59:44下載本文作者:會員上傳
簡介:寫寫幫文庫小編為你整理了多篇相關(guān)的《數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦]》,但愿對你工作學(xué)習(xí)有幫助,當(dāng)然你在寫寫幫文庫還可以找到更多《數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦]》。

第一篇:數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦]

實驗一

數(shù)據(jù)庫及表的創(chuàng)建與修改

一、實驗?zāi)康?/p>

1.熟悉掌握利用SSMS中的設(shè)計工具來創(chuàng)建表。修改表結(jié)構(gòu)以及查看表屬性等操作。

2.熟悉T-SQL的數(shù)據(jù)定義語言,能夠熟練地使用SQL語句創(chuàng)建和更改基本表。

二、實驗內(nèi)容

1.完成實驗教材中,實驗1.1的全部內(nèi)容。熟悉SQL SERVER的工作環(huán)境。

2、依照實驗1.2中的二維表,完成如下內(nèi)容。

1.利用SSMS中的設(shè)計工具為數(shù)據(jù)庫LibraryLib創(chuàng)建表表1-5所示的BookClass(圖書類別表)、1-6所示的Publish(出版社信息表)、表1-7所示的Book(圖書信息表)。

2.利用T-SQL創(chuàng)建新表1-

8、1-9與1-10。

3.修改表1-10 ExtraDateFee(超期罰款信息表):將FineMoney字段數(shù)據(jù)類型更改為:numeric(15,2);刪除Remarks字段;增加新字段Descript(varchar,70)。

4.利用T-SQL語句:刪除BookClass(圖書類別表),并重新創(chuàng)建該表。5.在SSMS中查看Book(圖書信息表)的屬性。

三、實驗步驟

1.利用SSMS中的設(shè)計工具為數(shù)據(jù)庫LibraryLib創(chuàng)建表。

表創(chuàng)建后的截圖如下: 表1-5:

表1-6:

表1-7:

2.T-SQL語句創(chuàng)建表:

創(chuàng)建表1-8: CREATE TABLE [Borrow]([BorrowID] [int] NOT NULL , [UserID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [BookID] [int] NOT NULL , [BorrowBeginDate] [datetime] NOT NULL , [BorrowEndDate] [datetime] NOT NULL , [ManagerID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , CONSTRAINT [PK_Borrow] PRIMARY KEY CLUSTERED([BorrowID])ON [PRIMARY])ON [PRIMARY]

創(chuàng)建表1-9:

CREATE TABLE [BorrowHistory]([BorrowID] [int] IDENTITY(1, 1)NOT NULL , [UserID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [BookID] [int] NOT NULL , [BorrowBeginDate] [datetime] NOT NULL , [BorrowEndDate] [datetime] NOT NULL , [BorrowReturnDate] [datetime] NOT NULL , [ManagerID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [ManagerReturnID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , CONSTRAINT [PK_BorrowHistory] PRIMARY KEY CLUSTERED([BorrowID])ON [PRIMARY])ON [PRIMARY] 創(chuàng)建表1-10: CREATE TABLE [ExtraDateFee]([BorrowID] [int] NOT NULL , [UserID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [BookID] [int] NOT NULL , [BorrowBeginDate] [datetime] NOT NULL , [BorrowEndDate] [datetime] NULL , [BorrowReturnDate] [datetime] NOT NULL , [ManagerID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [ManagerReturnID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [FineMoney] [money] NOT NULL , [TurnIn] [bit] NOT NULL , [ManagerFineID] [varchar](20)COLLATE Chinese_PRC_CI_AS NOT NULL , [Remarks] [char](10)COLLATE Chinese_PRC_CI_AS NOT NULL , CONSTRAINT [PK_ExtraDateFee] PRIMARY KEY CLUSTERED([BorrowID])ON [PRIMARY])ON [PRIMARY]

3.修改表1-10 ExtraDateFee(超期罰款信息表):將FineMoney字段數(shù)據(jù)類型更改為:numeric(15,2);刪除Remarks字段;增加新字段Descript(varchar,70)。

修改前:

修改后:

4.利用T-SQL語句:刪除BookClass(圖書類別表),并重新創(chuàng)建該表。刪除BookClass: Delete book: DELETE FROM [LibraryLib1].[dbo].[BookClass]

創(chuàng)建BookClass: Create book: CREATE TABLE [BookClass]([BookClassID] [int] IDENTITY(1, 1)NOT NULL , [BookClassName] [varchar](30)COLLATE Chinese_PRC_CI_AS NOT NULL , [BookBorrowDays]

[int]

NOT

NULL

CONSTRAINT [DF_BookClass_BookBorrowDays] DEFAULT(60), [BookFee] [money] NOT NULL , CONSTRAINT [PK_BookClass] PRIMARY KEY CLUSTERED

([BookClassID])ON [PRIMARY])ON [PRIMARY]

5.在SSMS中查看Book(圖書信息表)的屬性。

四、實驗心得

1.剛剛開始使用SQL servers進(jìn)行數(shù)據(jù)庫的建立及其操作,對這個平臺的功能還不大熟悉。在尋找功能鍵這一步就話了很多的時間。

2.實驗室安裝的平臺是SQL SERVERS 2005,但是實驗書上用的平臺是SQL SERVERS 2008,兩者使用的語句以及兩個平臺之間的功能都有一下差異,導(dǎo)致理解上有些困難。

3.雖然理論課上已經(jīng)學(xué)了很多SQL的操作語句,像表的建立,表的修改插入刪除等,但是由于平時沒有及時進(jìn)行實際的上機(jī)操作,感覺對SQL的語句掌握得不太好,以后會多實踐改進(jìn)。

第二篇:VFP講稿(創(chuàng)建數(shù)據(jù)庫和表)

第二部分

數(shù)據(jù)庫的創(chuàng)建與單命令

創(chuàng)建數(shù)據(jù)庫和表

一、Visual FoxPro 6.0的配置

P28

二、項目及其管理器

P31

1.項目的概念

項目:是文件、數(shù)據(jù)、文檔和Visual FoxPro對象的集合,被保存為擴(kuò)展名為PJX的文件。

建立項目可以對相關(guān)的內(nèi)容(項目的各組成部分)進(jìn)行統(tǒng)一組織、統(tǒng)一管理。

項目管理器:是Visual FoxPro中處理數(shù)據(jù)和對象的主要組織工具,是Visual FoxPro的“控制中心”。

項目管理器為其各個組成部分提供了一個組織良好的分層結(jié)構(gòu)視圖。利用項目管理器,用戶可以創(chuàng)建、修改、移出或刪除文件。只要簡單地單擊鼠標(biāo),就可以跟蹤表和查詢,組織表單、報表、標(biāo)簽、代碼、位圖和其它文件。

2.項目的創(chuàng)建

3.一個項目產(chǎn)生兩個文件.PJX和.PJT。4.打開/關(guān)閉項目 5.選項卡

三、Visual FoxPro 數(shù)據(jù)庫的基本操作

P93 1.建立數(shù)據(jù)庫

(1)在項目管理器中建立 *(2)從“新建”對話框中建立 *(3)用命令建立

P94(4)新建立的數(shù)據(jù)庫有三個文件

三個文件的擴(kuò)展名分別是:dbc

dct

dcx ? dbc數(shù)據(jù)庫文件的擴(kuò)展名 ? dct數(shù)據(jù)庫備注文件的擴(kuò)展名 ? dcx數(shù)據(jù)庫索引文件的擴(kuò)展名 2.打開和關(guān)閉數(shù)據(jù)庫(1)打開數(shù)據(jù)庫 有三種打開方法: ? 在項目管理器中打開 ? *從“打開”對話框中打開 ? *用命令打開

OPEN DATABASE命令

P95(2)關(guān)閉數(shù)據(jù)庫 CLOSE DATABASE 3.數(shù)據(jù)庫設(shè)計器

有三種打開方法: ? 在項目管理器中打開 ? *從“打開”對話框中打開 ? *用命令打開

MODIFY DATABASE命令

P98 4刪除數(shù)據(jù)庫

有兩種刪除方法: ? 在項目管理器中刪除 ? *用命令刪除

DELETE DATABASE命令

P99

四、數(shù)據(jù)庫表

1.建立數(shù)據(jù)庫表

P99(1)表設(shè)計器

(2)字段名:命名規(guī)則與內(nèi)存變量的命名規(guī)則相同。可與內(nèi)存變量同名。(3)字段類型和寬度(4)建立數(shù)據(jù)庫表產(chǎn)生的文件(5)字段有效性組框(6)用命令建立表

使用命令CREATE <表名> 有打開的數(shù)據(jù)庫時,建立的是數(shù)據(jù)庫表,否則建立的是自由表。2.修改表結(jié)構(gòu)

P102(1)插入字段(2)刪除字段(3)修改字段

(4)用命令MODIFY STRUCTURE打開表設(shè)計器進(jìn)行修改

五、自由表

如果當(dāng)前沒有打開數(shù)據(jù)庫,創(chuàng)建的表是自由表。1.創(chuàng)建自由表。

2.自由表和數(shù)據(jù)庫表的異同。

自由表和數(shù)據(jù)庫表的設(shè)計器不同。*數(shù)據(jù)庫表有很多附加信息。3.將自由表添加到數(shù)據(jù)庫。4.從數(shù)據(jù)庫中移出表。

第三篇:實驗2,數(shù)據(jù)庫表的創(chuàng)建與維護(hù)

《數(shù)據(jù)庫原理》實驗報告

實驗名稱 數(shù)據(jù)庫表/視圖的創(chuàng)建與維護(hù)實驗

班 級

2011211309

組 號

組員姓名 浦倩 楊洋

實驗?zāi)康?/p>

1. 掌握將E-R圖轉(zhuǎn)換為數(shù)據(jù)庫邏輯模式(關(guān)系表)的方法。

2. 通過進(jìn)行數(shù)據(jù)庫表的建立操作,熟悉并掌握在Microsoft SQL Server數(shù)據(jù)庫中建立表的方法,理解關(guān)系數(shù)據(jù)庫表的結(jié)構(gòu),鞏固SQL標(biāo)準(zhǔn)中關(guān)于數(shù)據(jù)庫表的建立語句。

3. 通過對Microsoft SQL Server數(shù)據(jù)庫中建立、維護(hù)視圖的實驗,熟悉Microsoft SQL Server數(shù)據(jù)庫中建立和維護(hù)視圖的方法,理解和掌握視圖的概念。

4. 掌握從Excel表向Microsoft SQL Server關(guān)系數(shù)據(jù)庫導(dǎo)入數(shù)據(jù)的方法,利用實際數(shù)據(jù)建立GSM網(wǎng)絡(luò)配置數(shù)據(jù)庫。實驗環(huán)境

采用Microsoft SQL Server數(shù)據(jù)庫管理系統(tǒng)作為實驗平臺。實驗內(nèi)容與步驟

1.閱讀《GSM移動通信網(wǎng)絡(luò)配置數(shù)據(jù)庫》課程實驗背景資料-11-v4.doc,將其中數(shù)據(jù)需求轉(zhuǎn)化為E-R圖。具體的E-R物理模型圖如下:(主鍵和外鍵關(guān)聯(lián)已在圖中顯示)

2.寫好SQL腳本文件(包括多個create table、create view等命令),一次性生成表和視圖,在Microsoft SQL Server中打開SQL腳本文件并執(zhí)行。寫好的SQL腳本見附錄。

3.數(shù)據(jù)導(dǎo)入

選擇要導(dǎo)入的數(shù)據(jù)源,原始數(shù)據(jù)要進(jìn)行去空行,刪除中文行等操作。

選擇要導(dǎo)入的數(shù)據(jù)庫名。

選擇復(fù)制整個表

將數(shù)據(jù)源和數(shù)據(jù)庫中的表對應(yīng)起來。

在映射數(shù)據(jù)屬性的時候,相同的名字系統(tǒng)會自動對應(yīng)。如果要導(dǎo)入的數(shù)據(jù)源和關(guān)系中屬性名字不相同的情況下,可以編輯映射將他們聯(lián)系起來。

成功導(dǎo)入數(shù)據(jù)。(因為導(dǎo)入數(shù)據(jù)可能出現(xiàn)一些小問題,所以本次實驗的所有實體數(shù)據(jù)是分開導(dǎo)入的。)

4.創(chuàng)建視圖(腳本見附錄)

A.在表“小區(qū)基本信息”上創(chuàng)建“LAC號為14121的小區(qū)基本位置信息”視圖CellInfo,屬性包括(CellID、所屬地區(qū)、LAC號、經(jīng)度、緯度)。

B.在表“20個小區(qū)一周分鐘級話務(wù)數(shù)據(jù)”上創(chuàng)建“全速率話務(wù)量平均值大于23的小區(qū)話務(wù)量數(shù)據(jù)信息”視圖CellCallInfo,屬性包括(CellID、平均半速率話務(wù)量率、平均擁塞率)。

C.創(chuàng)建“MscID = 5214的MSC管轄的BTS的基本信息,及其BTS對應(yīng)的天線基本信息。

附錄:(SQL腳本)

create view CellInfo as select CellID,AreaName,LAC,Longitude,Latitude from CELL where LAC=14121 go create view CellCallInfo as(select CELLID,avg(rate)as avg_r,avg(callcongs)as avg_c from HuaWu group by HuaWu.CELLID having avg(traff)>23)Go create view ParMscInfo as select BTS.*,Antenna.* from MSC,BSC,BTS,CELL,Antenna where MSC.MscId=5214 and MSC.MscId=BSC.MscId and BSC.BscId=BTS.BscId and BTS.BtsName=CELL.BtsName and CELL.CellId=Antenna.CellId go

use [victory] Go create table MSC(MscID int not null, MscName char(256)null, MscCompany char(256)null, MscLongitude float null, MscLatitude float null, MscAltitude float null, primary key(MscID))go

/*================*/ /* Table: BSC */ /*================*/ create table BSC(BscId int not null, BscName char(256)null, BscCompany char(256)null, Latitude float null, Longitude float null, MscID int null, primary key(BscId), foreign key(MscID)references MSC)go

/*================*/ /* Table: BTS */ /*================*/ create table BTS(Btsname char(256)not null, BscId int null, Latitude float null, Longitude float null, Altitude float null, BtsCompany char(256)null, BtsPower int null, primary key(Btsname), foreign key(BscId)references BSC)go

/*================*/ /* Table: MS */ /*================*/ create table MS(IMEI char(256)not null, MSISDN char(256)null, UserName char(256)null, MSCompany char(256)null, gsmMspSense float null, gsmMsHeight float null, gsmMspFout float null, MZONE char(256)null, primary key(IMEI))go

/*================*/ /* Table: “CELL” */ /*================*/ create table “CELL”(CellID int not null, LAC int not null, BtsName char(256)null, AreaName char(256)null, Longitude float null, Latitude float null, Direction float null, Bcch int null, primary key(CellID), foreign key(BtsName)references BTS)go create table Antenna(CellID int not null, AntennaHeight float null, HalfPAngle float null, MaxAttenuation float null, Gain float null, AntTilt float null, Pt float null, MsPwt float null, primary key(CellID), foreign key(CellID)references CELL)go

/*================*/ /* Table: PinDian */ /*================*/ create table PinDian(CellID int not null, Freq char(256)not null, primary key(CellID,Freq), foreign key(CellID)references CELL)go

/*================*/ /* Table: LinQu */ /*================*/ create table LinQu(CellID int not null, AdjCellId int null, CellLac float null, AdjCellLac float null, foreign key(CellID)references CELL)go

/*================*/ /* Table: LuCe */ /*================*/ create table LuCe(KeyNum int not null, CellID int null, Latitude float null, Longitude float null, RxLev float null, primary key(KeyNum), foreign key(CellID)references CELL)go

/*================*/ /* Table: HuaWu */ /*================*/ create table HuaWu(CellID int not null, DATA datetime not null, TIME datetime not null, nTCH float null, traff float null, rate float null, thtraff float null, callnum float null, congsnum float null, callcongs float null, primary key(DATA,TIME,CellID), foreign key(CellID)references CELL)go

實驗要求 本實驗內(nèi)容比較繁多,要求同學(xué)一定要進(jìn)行完全的實驗,并做出詳盡的記錄。

實驗總結(jié)

通過本次實驗,掌握了如何使用SQL語言創(chuàng)建新的關(guān)系,以及設(shè)置主鍵和外鍵。在創(chuàng)建外鍵的時候,要注意其引用的主鍵要在其之前創(chuàng)建,也就是說,在實驗開始的時候,我們沒有注意到創(chuàng)建不同的關(guān)系的順序問題,導(dǎo)致不能夠成功執(zhí)行腳本。在導(dǎo)入數(shù)據(jù)的過程中,一周內(nèi)的話務(wù)信息不能夠成功導(dǎo)入,問題是話務(wù)信息的主鍵DATA和TIME,僅由這兩個屬性不能夠唯一確定一次話務(wù)信息,所以我們只能刪除主鍵,將話務(wù)數(shù)據(jù)導(dǎo)入。另外的問題是,數(shù)據(jù)源的屬性名稱可能與數(shù)據(jù)庫中的屬性名稱不同,這時導(dǎo)入數(shù)據(jù)時系統(tǒng)不能夠自動映射出他們之間的關(guān)系,所以要在導(dǎo)入數(shù)據(jù)時手動編輯映射。編輯腳本語言時,要注意視圖必須在最前面。總之,雖然在實驗之前已經(jīng)較熟悉SQL語言的相應(yīng)應(yīng)用,但是在實驗的過程中仍然會出現(xiàn)很多問題,這讓我們收獲了耐心嚴(yán)謹(jǐn)?shù)膶W(xué)習(xí)態(tài)度。

第四篇:oracle-sql語句-創(chuàng)建表空間、數(shù)據(jù)庫

1、查看表空間的名稱及大小

select t.tablespace_name, round(sum(bytes/(1024*1024)),0)ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name;

2、查看表空間物理文件的名稱及大小

select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0)total_space from dba_data_files order by tablespace_name;

3、查看回滾段名稱及大小

select segment_name, tablespace_name, r.status,(initial_extent/1024)InitialExtent,(next_extent/1024)NextExtent, max_extents, v.curext CurExtent From dba_rollback_segs r, v$rollstat v Where r.segment_id = v.usn(+)order by segment_name;

4、查看控制文件

select name from v$controlfile;獲取創(chuàng)建表空間的sql select

dbms_lob.substr(dbms_metadata.get_ddl('TABLESPACE',a.tablespace_name))from dba_tablespaces a;

SQL> select sid,serial# from v$session where username='TEST';alter system kill session '150,9019';查看被鎖的表 select object_name,machine,s.sid,s.serial#,s.event from gv$locked_object l,dba_objects o,gv$session s where l.object_id=o.object_id and l.session_id=s.sid;alter system kill session ‘sid,serial#’;

5、查看日志文件

select member from v$logfile;

6、查看表空間的使用情況

select sum(bytes)/(1024*1024)as free_space,tablespace_name from dba_free_space group by tablespace_name;

SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,(B.BYTES*100)/A.BYTES “% USED”,(C.BYTES*100)/A.BYTES “% FREE” FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;

Select b.tablespace_name as表空間名,b.bytes as字節(jié)數(shù),(b.bytes-sum(nvl(a.bytes,0)))as已使用,sum(nvl(a.bytes,0))as剩余空間,sum(nvl(a.bytes,0))/(b.bytes)*100 as 剩余百分比 from dba_free_space a,dba_data_files b where a.file_id=b.file_id group by b.tablespace_name,b.file_id,b.bytes order by b.file_id;

7、查看數(shù)據(jù)庫庫對象

select owner, object_type, status, count(*)count# from all_objects group by owner, object_type, status;

8、查看數(shù)據(jù)庫的版本

Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle';

9.查看某個表空間內(nèi)所占空間大于某個值的段(表或索引):

Select segment_name,bytes FROM dba_segments Where bytes>10000000 AND tablespace_name='tablespace_name';10.查看所有表空間的碎片程度(值在30以下表示碎片很多)

select tablespace_name,sum(bytes),sum(free),sum(free)*100/sum(bytes)from(select

b.file_id file_ID,b.tablespace_name tablespace_name,b.bytes Bytes,(b.bytes-sum(nvl(a.bytes,0)))used,sum(nvl(a.bytes,0))free,sum(nvl(a.bytes,0))/(b.bytes)*100

Percent

from dba_free_space a,dba_data_files b

where a.file_id=b.file_id

group by b.tablespace_name,b.file_id,b.bytes

order by b.file_id)group by tablespace_name order by sum(free)*100/sum(bytes);11.查看自上次數(shù)據(jù)庫啟動以來所有數(shù)據(jù)文件的讀寫次數(shù)

select

substr(DF.NAME,1,5)Drive,DF.NAME file_name,(fs.phyblkrd+fs.phyblkwrt)

from v$filestat fs,v$datafile df

where df.file#=fs.file#;

創(chuàng)建臨時表空間: //創(chuàng)建臨時表空間

create temporary tablespace mytest tempfile 'E:/Program/oracle/product/10.1.0/oradata/orcl/mytest.dbf' size 32m autoextend on next 32m maxsize 1024m extent management local;

//創(chuàng)建數(shù)據(jù)表空間

create tablespace mytest_data logging datafile 'E:/Program/oracle/product/10.1.0/oradata/orcl/mytest_data.dbf' size 32m autoextend on next 32m maxsize 1024m extent management local;//創(chuàng)建用戶并指定表空間

create user testaccount identified by testpwd default tablespace mytest_data temporary tablespace mytest;//給用戶授予權(quán)限

grant connect,resource to testaccount;(db2:指定所有權(quán)限)12,創(chuàng)建一個用戶:

CREATE USER username IDENTIFIED BY password OR IDENTIFIED EXETERNALLYOR IDENTIFIED GLOBALLY AS ‘CN=user’[DEFAULT TABLESPACE tablespace][TEMPORARY TABLESPACE temptablespace][QUOTA [integer K[M] ] [UNLIMITED] ] ON tablespace[,QUOTA [integer K[M] ] [UNLIMITED] ] ON tablespace[PROFILES profile_name][PASSWORD EXPIRE][ACCOUNT LOCK or ACCOUNT UNLOCK];

//查看數(shù)據(jù)庫中的所有用戶: select * from all_users;//or select * from dba_users 13查看oracle最大連接數(shù): Select session_max,session_current,sessions_highwater,users_max from v$license;Select username,count(username)from v$session group by username;加密存儲過程 WRAP

INAME=D:ORACLESOURCEDATE.SQL ONAME=D:ORACLESOURCEDATA.PLD

第五篇:圖書管理系統(tǒng)--創(chuàng)建數(shù)據(jù)庫和表

/* 1管理員表(L_Administrator)字段名 字段說明 數(shù)據(jù)類型 約束 備注 a_id 管理員編號 int Primary Key Identity(1000,1)a_name 管理員姓名 nvarchar(20)Not null a_pwd */ use Library go create table L_Administrator(a_id int not null primary key Identity(1000,1), a_name nvarchar(20)not null, a_pwd varchar(20)not null);

/* 2職務(wù)類型表(L_Duty)字段名 字段說明 數(shù)據(jù)類型 約束 備注 d_id 職務(wù)編號 int Primary Key Identity(1000,1)d_name 職務(wù)名稱 nvarchar(20)Not null d_maxcount 最大借閱數(shù)量 tinyint Not Null */ use Library go create table L_Duty(d_id int not null primary key Identity(1000,1), d_name nvarchar(20)not null, d_maxcount tinyint not null);

/* 3讀者表(L_Reader)字段名 字段說明 數(shù)據(jù)類型 管理員密碼 varchar(20)

Not Null

約束 備注

r_id 讀者編號 bigint Primary Key r_name 讀者姓名 nvarchar(20)Not Null r_pwd r_sex 讀者密碼 讀者性別 varchar(20)Not Null bit Not Null

int Foreign Key 職務(wù)類型表的主鍵

r_typeid 職務(wù)類型

r_academy 所在院系 nVarchar(20)r_major 專業(yè) nVarchar(20)

r_contact 聯(lián)系方式 Varchar(20)r_email 郵箱 nvarchar(20)

r_photo 讀者照片 */ use Library nVarchar(100)

存的是讀者照片的路徑 go create table L_Reader(r_id bigint not null primary key, r_name nvarchar(20)not null, r_pwd varchar(20)not null, r_sex bit not null, r_typeid int not null, r_academy nvarchar(20), r_major nvarchar(20), r_contact varchar(20), r_email varchar(20), r_photo nvarchar(100));alter table L_Reader add constraint fk_dtypeid foreign key(r_typeid)references L_Duty(d_id)on delete cascade on update cascade;

/*創(chuàng)建一個存儲過程*/ use Library go create procedure reader @r_id bigint, @r_name nvarchar(20), @r_pwd varchar(20), @r_sex bit, @r_typeid int, @r_academy nvarchar(20), @r_major nvarchar(20), @r_contact varchar(20), @r_email varchar(20), @r_photo nvarchar(100)as begin insert into L_Reader(r_id,r_name,r_pwd,r_sex,r_typeid,r_academy,r_major,r_contact,r_email,r_photo)values(@r_id,@r_name,@r_pwd,@r_sex,@r_typeid,@r_academy,@r_major,@r_contact,@r_email,@r_photo);end /* 4圖書類型表(L_BookType)字段名 字段說明 數(shù)據(jù)類型 bt_id 類型編號 bt_name 類型名稱 */

約束 備注

int Primary Key Identity(1000,1)nVarchar(20)Not null use Library go create table L_BookType(bt_id int not null primary key Identity(1000,1), bt_name nvarchar(20)not null);

/* 5出版社信息表(L_Publishing)字段名 字段說明 數(shù)據(jù)類型 ISBN */ use Library go create table L_Publishing(ISBN char(13)not null primary key, p_name nvarchar(30)not null);

/* 6圖書信息表(L_Book)字段名 字段說明 數(shù)據(jù)類型 國際標(biāo)準(zhǔn)圖書編碼

約束 備注

char(13)Primary Key

p_name 出版社名稱 nvarchar(30)Not Null

約束 備注

b_id 圖書編號 Varchar(30)Primary Key Identity(1000,1)b_name 圖書名稱 nvarchar(30)Not Null ISBN 國際標(biāo)準(zhǔn)圖書編碼 char(13)Foreign Key 13位數(shù)字組成 b_bkcaseid 書架編號 Varchar(20)

b_price 定價 b_author 作者 Numeric(10,2)nvarchar(20)

b_typeid 類型編號 int Foreign Key b_intime 入庫時間 DateTime b_synopsis 圖書簡介 Nvarchar(500)b_state 圖書狀態(tài) b_photo 封面圖片 */ use Library go

create table L_Book(b_id varchar(20)not null primary key , b_name nvarchar(30)not null, ISBN char(13), b_bkcaseid varchar(20), b_price Numeric(10,2)not null, b_author nvarchar(20), b_typeid int, b_intime DateTime,bit 0--借出,1--沒有借出 Nvarchar(100)存的是路徑 b_synopsis nvarchar(1000), b_state bit not null default 0, b_photo nvarchar(100));

alter table L_Book add L_BookType(bt_id)on delete cascade on update cascade;alter table L_Book add constraint fk_bisbn foreign key(ISBN)references L_Publishing(ISBN)on delete cascade on update cascade;alter table L_Book drop column b_bkcaseid /*創(chuàng)建存儲過程*/ use Library go create procedure book @b_name nvarchar(30), @ISBN char(13), @b_bkcaseid varchar(20), @b_price numeric(10,2), @b_author nvarchar(20), @b_intime datetime,@b_synopsis nvarchar(1000), @b_photo nvarchar(100)as begin insert into L_Book(b_name,ISBN,b_bkcaseid,b_price,b_author,b_intime,b_synopsis,b_photo)values(@b_name,@ISBN,@b_bkcaseid,@b_price,@b_author,@b_intime,@b_synopsis,@b_photo);end /* 7借閱管理表(L_Borrow)字段名 字段說明 數(shù)據(jù)類型

constraint fk_btypeid foreign key(b_typeid)references

約束 備注

bw_id 借閱編號 int Primary Key Identity(1,1)bw_bookid 圖書編號 Varchar(20)Foreign Key bw_readerid 讀者編號 bw_outtime 借出日期 bw_endtime 到期日期 bw_backtime 歸還日期 bw_isexpired 是否過期 bw_fine 罰款數(shù)目 */ use Library

Int Foreign Key DateTimeNot Null DateTimeNot Null

DateTime

Bit Not Null 默認(rèn)為0--不過期

過期后才計算罰款數(shù)目 Numeric(10,2)go create table L_Borrow(bw_id int not null primary key Identity(1,1), bw_bookid varchar(20), bw_readerid bigint , bw_outtime datetime not null,bw_endtime as dateadd(d,30,bw_outtime), bw_backtime datetime, bw_isexperied bit default 0, bw_fine numeric(10,2)default 0.00);alter table L_Borrow add constraint fk_bookid foreign key(bw_bookid)references L_Book(b_id)on delete cascade on update cascade;alter table L_Borrow add constraint fk_readerid foreign key(bw_readerid)references L_Reader(r_id)on delete cascade on update cascade;/* 8圖書資源表(L_Resource)字段名 字段說明 數(shù)據(jù)類型

約束 備注

rs_id 資源編號 Int Primary Key Identity(1000,1)rs_name 資源名稱 nVarchar(30)Not null rs_synopsis 資源簡介 nVarchar(500)rs_amount 資源大小 int 單位為KB或是MB rs_type 資源類型 等常用格式 */ use Library go create table L_Resource(rs_id int not null primary key Identity(1000,1), rs_name nvarchar(30)not null, rs_synopsis nvarchar(500), rs_amount bigint, rs_type varchar(20));

/* 9圖書評論表(L_BookMarks)

字段名 字段說明 數(shù)據(jù)類型 約束 備注 ISBN 國際標(biāo)準(zhǔn)圖書編碼 char(13)Foreign Key bm_contents 評論內(nèi)容 Nvarchar(500)Not Null bm_time 評論時間 DateTimeNot Null */ Varchar(20)

類似于doc、xsl、ppt、pdf、zip、rar、MP3、wmvuse Library go create table L_BookMarks(ISBN char(13)not null, bm_contents nvarchar(500)not null, bm_time datetime not null);alter table L_BookMarks add constraint fk_bmisbn foreign key(ISBN)references L_Publishing(ISBN)on delete cascade on update cascade;/* 10書架信息表(L_BookCase)字段名 字段說明 數(shù)據(jù)類型 約束 備注

bc_id 書架編號 int Primary Key Identity(1000,1)bc_typeid 類型編號 int Foreign Key

*/ use Library go create table L_BookCase(bc_id int not null primary key Identity(1000,1), bc_typeid int not null);alter table L_BookCase add constraint fk_bctypeid foreign key(bc_typeid)L_BookType(bt_id);

references

下載數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦]word格式文檔
下載數(shù)據(jù)庫及表的創(chuàng)建與修改[本站推薦].doc
將本文檔下載到自己電腦,方便修改和收藏,請勿使用迅雷等下載。
點(diǎn)此處下載文檔

文檔為doc格式


聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻(xiàn)自行上傳,本網(wǎng)站不擁有所有權(quán),未作人工編輯處理,也不承擔(dān)相關(guān)法律責(zé)任。如果您發(fā)現(xiàn)有涉嫌版權(quán)的內(nèi)容,歡迎發(fā)送郵件至:645879355@qq.com 進(jìn)行舉報,并提供相關(guān)證據(jù),工作人員會在5個工作日內(nèi)聯(lián)系你,一經(jīng)查實,本站將立刻刪除涉嫌侵權(quán)內(nèi)容。

相關(guān)范文推薦

    數(shù)據(jù)庫和表的創(chuàng)建與管理實驗報告(共5則)

    南京信息工程大學(xué)實驗(實習(xí))報告 實驗(實習(xí))名稱 數(shù)據(jù)庫和表的創(chuàng)建與管理 實驗(實習(xí))日期得分指導(dǎo)教師系計算機(jī) 專業(yè) 計算機(jī)科學(xué)與技術(shù) 年級班次姓名學(xué)號 一、實驗?zāi)康?1.熟悉SQL......

    Oracle 數(shù)據(jù)庫表空間(tablespace)的創(chuàng)建、刪除、修改、擴(kuò)展以及檢查(小編推薦)

    Oracle 數(shù)據(jù)庫表空間(tablespace)的創(chuàng)建、刪除、修改、擴(kuò)展以及檢查-------------oracle 數(shù)據(jù)庫表空間學(xué)習(xí)--------------------- --oracle 數(shù)據(jù)庫表空間的作用 1.決定數(shù)......

    Geodatabase 數(shù)據(jù)庫創(chuàng)建

    Geodatabase 數(shù)據(jù)庫創(chuàng)建 1 Geodatabase概述 地理數(shù)據(jù)庫(GeoDatabase) 是為了更好的管理和使用地理要素數(shù)據(jù),而按照一定的模型、規(guī)則組合起來的存儲空間數(shù)據(jù)和屬性數(shù)據(jù)的容器。......

    修改數(shù)據(jù)庫狀態(tài)以便修改歸檔模式

    SQL*Plus: Release 10.2.0.1.0Production With the Partitioning, OLAP and Data Mining options第一步【關(guān)閉數(shù)據(jù)庫】: shutdown immediate; 數(shù)據(jù)庫已經(jīng)關(guān)閉。 已經(jīng)卸載數(shù)據(jù)......

    第二章 數(shù)據(jù)庫和表的操作

    第二章 數(shù)據(jù)庫和表的操作 首先創(chuàng)建名為“教學(xué)管理”的數(shù)據(jù)庫,完成以下操作: 1. 在數(shù)據(jù)庫中,建立“教師表”,表結(jié)構(gòu)如下: 教師表(教師編號,姓名,性別,工作時間,政治面貌,學(xué)歷,職稱,系別,電......

    access創(chuàng)建數(shù)據(jù)庫-教案

    創(chuàng)建數(shù)據(jù)庫 計算機(jī)組 余金光 一.教學(xué)重點(diǎn) 1.數(shù)據(jù)庫的創(chuàng)建方法 2.退出數(shù)據(jù)庫 二.教學(xué)難點(diǎn) 打開數(shù)據(jù)庫的方法和退出關(guān)閉數(shù)據(jù)庫的方法 三.教學(xué)方法 演示法,討論法,講授法,練習(xí)法 四.教......

    創(chuàng)建數(shù)據(jù)庫的相關(guān)知識

    create database PeronalBlog/*創(chuàng)建文章內(nèi)容表(id, 標(biāo)題,內(nèi)容,關(guān)鍵字)*/ create table TitleInfo( Tid varchar(20) primary key, Ttile varchar(20) not null, Ttext varchar(80......

    Oracle數(shù)據(jù)庫創(chuàng)建表空間、建立用戶、授權(quán)、還原備份

    創(chuàng)建用戶一般分四步: 第一步:創(chuàng)建臨時表空間 第二步:創(chuàng)建數(shù)據(jù)表空間 第三步:創(chuàng)建用戶并制定表空間 第四步:給用戶授予權(quán)限 --Oracle創(chuàng)建臨時表空間 如果沒有指定的臨時表空間,則可......

主站蜘蛛池模板: 中文字幕乱码无码人妻系列蜜桃| 国产精品久久久久永久免费看| 无码三级在线看中文字幕完整版| 精品亚洲麻豆1区2区3区| 99久久精品日本一区二区免费| 久久亚洲欧美国产精品| 人妻少妇被猛烈进入中文字幕| 国产精品无码无片在线观看3d| 国产三级精品三级在线专区| 亚洲人成网77777色在线播放| 国产精品自在拍首页视频8| 66亚洲一卡2卡新区成片发布| 国产在线精品一区在线观看| 日日碰狠狠躁久久躁96| 亚洲综合精品伊人久久| 亚洲人成图片小说网站| 亚洲精品无码你懂的| 亚洲国产欧美在线人成aaaa| 成人欧美日韩一区二区三区| 色综合伊人色综合网站无码| 无码成人一区二区| 久久人人妻人人爽人人爽| 日本免费一区二区三区日本| 国产精品丝袜亚洲熟女| 夜色毛片永久免费| 激情五月综合色婷婷一区二区| 亚洲国产中文字幕在线视频综合| 欧美精品久久96人妻无码| 1区2区3区高清视频| 久久精品水蜜桃av综合天堂| 久久久久久国产精品无码超碰动画| 午夜少妇性开放影院| 亚洲伊人五月丁香激情| 欧美激情一区二区三区高清视频| 97久久超碰国产精品旧版麻豆| 亚洲精品无码日韩国产不卡av| 亚洲熟女中文字幕男人总站| 亚洲av久久久噜噜噜噜| 亚洲精品无码专区久久久| 国产成人精品一区二区秒拍| 国产在线精品一区二区不卡|