【正文】
答案 ( 1) create trigger tri1 on Table_SaleBill for insert, update as declare score int select score = Score from inserted update Table_Card set Score = Score + score where CardID in ( select CardID from inserted ) ( 2) create trigger tri2 on Table_SaleBillDetail for insert, update as update Table_SaleBill set PayAmount = ( select sum() from Table_SaleBillDetail a join inserted b on = ) where SaleBillID in ( select SaleBillID from inserted) ( 3) (a) 后觸發(fā)型觸發(fā)器: create trigger tri3_1 on T。 return count end ( 3) create function f3(low int, high int) returns table as return ( select CName,Address,GoodsName,SaleDate,Quantity from Table_Customer a join Table_SaleBill b on = join Table_SaleBillDetail c on = join Table_Goods d on = where Age between low and high) ( 4) create function f4(lb varchar(20), nf int) returns table as return (select GoodsName,SaleDate,Quantity,(lb,nf) as total from Table_SaleBill a join Table_SaleBillDetail b on = join Table_Goods c on = join Table_GoodsClass d on = where GoodsClassName = lb and year(SaleDate) = nf) ( 5) create function f5(lb varchar(20)) returns new_table table ( 商品名稱 varchar(30), 單價(jià) money, 銷售日期 datetime, 銷售數(shù)量 int, 銷售總價(jià) money) as begin insert into new_table select GoodsName, SaleUnitPrice, SaleDate,Quantity, Amount from Table_Goods a join Table_SaleBillDetail b on = join Table_SaleBill c on = join Table_GoodsClass d on = where GoodsClassName = lb return end 答案 觸發(fā)器的主要作用是: 完成比 CHECK 約束更復(fù)雜的數(shù)據(jù)約束,為保證數(shù)據(jù)庫性能而維護(hù)的非規(guī)范化數(shù)據(jù)以及實(shí)現(xiàn)復(fù)雜的業(yè)務(wù)規(guī)則 。 ( 4) create proc p4 as update Table_SaleBillDetail set Discount = case when 10000 then when between 5000 and 10000 then when between 1000 and 4999 then else 1 end from Table_SaleBillDetail a join Table_SaleBill b on = join Table_Card c on = 答案 ( 1) create function (lb varchar(20), nf int) returns int as begin declare sum int select sum = sum(Quantity) from Table_SaleBillDetail a join Table_SaleBill b on = join Table_Goods c on = join Table_GoodsClass d on = where GoodsClassName = lb and year(SaleDate) = nf return sum end ( 2) create function (addr varchar(20)) returns int as begin declare count int select count = count(*) from Table_Card a join Table_Customer b on = where address = addr and State = 39。,mon int as select day(SaleDate), sum(PayAmount) from Table_SaleBill a join Table_SaleBillDetail b on = join Table_Goods c on = join Table_GoodsClass d on = where GoodsClassName = lb and month(SaleDate) = mon group by day(SaleDate) ( 3) create proc p3 lb varchar(20),sum money output as if exists(select * from able_GoodsClass where GoodsClassName = lb) select sum = sum(PayAmount) from Table_SaleBill a join Table_SaleBillDetail b on = join Table_Goods c on = join Table_GoodsClass d on = where GoodsClassName = lb else print 39。 答案 ( 1) create proc p1 lb varchar(20) as select CName,Address,GoodsName,SaleDate,Quantity from Table_Customer a join Table_SaleBill b on = join Table_SaleBillDetail c on = join Table_Goods d on = join Table_GoodsClass e on = where GoodsClassName = lb ( 2) create proc p2 lb varchar(20) = 39。 答案 DECLARE i int, res int SET i = 1 SET res = 5000 while i = 100 begin SET res = res i SET i = i + 1 end print res 答案 :不必相同。 160MB。 答案 :按數(shù)據(jù)頁存儲(chǔ),一個(gè)數(shù)據(jù) 頁大小是 8KB。 答案 :可以包含一個(gè)主數(shù)據(jù)文件和 0~ n 個(gè)輔助數(shù)據(jù)文件, 1~ n 個(gè)日志文件。 答案 有數(shù)據(jù)文件和日志文件。 model是用戶數(shù)據(jù)庫的樣板數(shù)據(jù) 庫,其中包含所有用戶數(shù)據(jù)庫的公共信息。包括登錄帳戶、系統(tǒng)配置、數(shù)據(jù)庫屬性(如數(shù)據(jù)庫文件的位置等)等信息。 答案 master、 model、 msdb、 tempdb。 答案 :啟動(dòng) SQL Server 服務(wù)。 答案 “ Windows 身份驗(yàn)證模式 ” 只允許 Windows 用戶連接到 SQL Server,而“ 混合模式 ”允許 Windows 用戶和非 Windows 用戶連接到 SQL Server。 答案 四個(gè)版本:企業(yè)版、標(biāo)準(zhǔn)版、個(gè)人版和開發(fā)版。 DTC是一個(gè)事務(wù)管理器, 它能夠保證一個(gè)事務(wù)中的所有操作在所有的服務(wù)器上全部成功,或者,當(dāng)在某個(gè)服務(wù)器上不成功時(shí),確保所有服務(wù)器上的操作均被撤消,使全部服務(wù)器均回到事務(wù)開始前的狀態(tài)。 SQL Server Agent管理需要定期進(jìn)行的工作,它 能夠根據(jù)系統(tǒng)管理員預(yù)先設(shè)定好的計(jì)劃自動(dòng)執(zhí)行相應(yīng)的功能。 第 11章習(xí)題參考答案 答案 ( 1) C ( 2) D ( 3) D ( 4) C 答案 ( 1) 事務(wù)內(nèi)部的故障、系統(tǒng)故障、介質(zhì)故障以及計(jì)算機(jī)病毒故障 ( 2)冗余數(shù)據(jù) ( 3) 靜態(tài)轉(zhuǎn)儲(chǔ)、動(dòng)態(tài)轉(zhuǎn)儲(chǔ) ( 4) 每個(gè)事務(wù)的開始標(biāo)記、每個(gè)事務(wù)的結(jié)束標(biāo)記 ( 5) 必須先寫日志文件,后寫數(shù)據(jù)庫 ( 6) 雙機(jī)互備援模式、雙機(jī)熱備份模式 ( 7) 校驗(yàn)冗余 第 12章習(xí)題參考答案 答案 四個(gè)服務(wù): SQL Server、 SQL Server Agent、 Distributed Transaction Coordinator( DTC)和