資料操縱語言dml(增刪改)
(1)使用transact_sql語句建立「student_db」資料庫,資料檔案的邏輯稱為「student_db.data」,儲存到d盤的data1資料夾中,檔名為「student_db.mdf」,資料檔案初始儲存空間大小為10mb,最大儲存空間為50mb,儲存空間自動增長量為2mb;日誌檔案的邏輯名稱為」tudent_db_log」,儲存位置與資料檔案相同,檔名為「student_db.ldf」,初始儲存空間大小誒8mb,最大儲存空間為40mb,儲存空間自動增長量為15%。
課本p78 例3-1 的例題。模擬題(2)已知以後teacher 表結構如下,請使用transact-sql語句定義teacher表。
欄位名稱
資料型別
字段長度是否為空
pkfk
其他約束
字段說明
tnochar10n
y職工號
tname
varchar25n
姓名t***
char2y
預設為男
性別tsalary
intn
[5000,8000]
工資tprof
varchar10y
職稱答案
create
table teacher
( tno char(10
)primary
key,
tname varchar(25
)not
null
, t*** char(2
)default 『男』 check
(t***=』男』 or t*** = 『女』),
tsalary int
notnull
check
(tsalary)
>=
5000
and tsalary <=
8000
, tprof varchar(10
))
資料操縱語言dml 主要包括新增資料、修改資料和刪除資料三類語句
create
procedure pro1
@tno
char(20
)asselect form teacher
where tno=
@tno
update course
set cname = 『資料結構』
where cname = 『資料庫』
select
* form teacher
where dno in(select dno
form teacher
where tname=『王珂』
)
方法一
select tno,tname,dno
from teacher,course,tc
where cname=』資料庫』and teacher.tno= tc.tno and tc.cno=course.cno
方法二 select tno ,tname,dno
form teacher
where tno in
(select tno form course,tc
where cname =』資料庫』 and tc.cno = course.cno
)
資料庫總結
從這張表可以看到存在冗餘,西遊記,孫悟空 和 葫蘆娃,火娃 出現兩次,在資料量更大的情況下可能出現更多次。假設用這張表,然後候選鍵為什麼?你分析一下,小朋友的id肯定是候選鍵 候選鍵的概念,請翻閱資料庫教材 之一,就可以了麼。貌似不行,因為動漫電影不由這個決定,那麼動漫人物加上作為候選鍵之一,根據這...
資料庫總結
剛剛結束了short brain 英語學習的專案,趕快利用這段時間把期末考試期間拉下的資料庫的學習趕一下吧。雖然相隔時間不長,但是我已經對資料庫的概念和了解有一些模糊了。於是翻開了以前的相關筆記複習了一下,幫我喚起了部分的記憶。我在資料庫學習的初期參考了vb課本以及 sql入門經典 並且在學習的初期...
資料庫總結
一 常見資料庫 1 oracle是甲骨文的資料庫產品2 sql server是微軟的資料庫產品3 mysql是一種開源 的關係型資料庫管理系統 資料庫管理系統 dbms 資料庫管理員 dba 資料庫系統 dbs 二 1 dml 資料操作語言 用來插入 修改和刪除資料庫中的資料2 ddl 資料定義語言...