




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、PAGE7數(shù)據(jù)庫原理實驗報告題目:實驗五 安全性及事務(wù)操作學(xué)號:成績班級: 計算12日期:姓名:指導(dǎo)老師:林穎賢一、實驗?zāi)康模?、掌握SQL Server的安全機制; 2、掌握服務(wù)器的安全性的管理;3、掌握數(shù)據(jù)庫用戶的管理;4、掌握權(quán)限的管理。二、實驗使用環(huán)境:Windows 7 x64、SQL Server 2005三、實驗內(nèi)容與完成情況:1、安全性綜合實驗1)設(shè)計安全機制使得用戶“test”只能查詢采購部門的職工。 sp_addlogin test,123execute sp_grantdbaccess test,wangmingcreate view V_empasselect * fr
2、om Employeeswhere Emp_depart=采購部grant select on V_emp to wangmingselect * from V_emp2)設(shè)計角色“Employees”,可以查看“職工”的職工號與姓名。并將用戶“test”作為成員加入角色“Employees”, 這樣用戶“test”只能查看“職工”的職工號與姓名。 exec sp_addrole employeesp_addrolemember employee,wangmingcreate view V_Role_Empasselect Emp_no,Emp_name from Employeesgrant
3、 select on V_Role_Emp to employeeselect * from V_Role_Emp3)請進行安全設(shè)置,用戶李建國師擁有以下權(quán)力:他要能查進貨表中的信息,并擁有對自已進貨的信息修改的權(quán)限,其它表的信息無權(quán)查看。sp_addlogin test1,123exec sp_grantdbaccess test1,李建國create view V_Liasselect * from Purchase where Emp_no in(select Emp_no from employees where Emp_name=李建國)grant select,update on
4、V_Li to 李建國grant select on Purchase to 李建國4)如何使得采購部門的員工都具有這樣的權(quán)限:能查看進貨表的信息,并擁有對自已采購信息的修改,其它的信息無權(quán)查看。(要求:編寫存儲過程proc_stu_grant,其作用:輸入?yún)?shù)為員工姓名,從進貨表中查找該員工所進貨的產(chǎn)品,如果沒有則返回,有的話則相應(yīng)的在login表中添加賬號和密碼。并且,創(chuàng)建相應(yīng)的登錄賬號和數(shù)據(jù)庫用戶)create proc proc_emp_grant Emp_name nvarchar(10)asbegindeclare sqlstr varchar(255)declare sqlvie
5、w varchar(14)if exists (select Pur_no from Purchase where Emp_no in (select Emp_no from Employees where Emp_name=Emp_name) begin set sqlview=Emp_name+_view set sqlstr=create view +sqlview+ as select * from Purchase where Emp_no in(select Emp_no from employees where Emp_name=+Emp_name+) exec(sqlstr)
6、exec sp_addlogin Emp_name,123456 exec sp_grantdbaccess Emp_name,Emp_name set sqlstr=grant select on Purchase to +Emp_name exec(sqlstr) set sqlstr=grant select,update on +sqlview+ to +Emp_name exec(sqlstr) endelse print沒有該員工的進貨信息!endexec proc_emp_grant 趙明exec proc_emp_grant 趙哈哈5)銀行轉(zhuǎn)賬問題CREATE TABLE ba
7、nk -創(chuàng)建賬戶表,存放用戶的賬戶信息( customerName CHAR(10), -顧客姓名 currentMoney MONEY -當(dāng)前余額)GO-添加約束:根據(jù)銀行規(guī)定,賬戶余額不能少于1元,否則視為銷戶 ALTER TABLE bank ADD CONSTRAINT CK_currentMoney CHECK(currentMoney=1)GO-張三開戶,開戶金額為1000元 ;李四開戶,開戶金額1元 INSERT INTO bank(customerName,currentMoney) VALUES(張三,1000)INSERT INTO bank(customerName,cu
8、rrentMoney) VALUES(李四,1)寫出用事務(wù)解決銀行轉(zhuǎn)賬的存儲過程:create table bank( customerName char(10), currentMoney money)alter table bank add constraint ck_currentMoney check(currentMoney=1)insert into bank(customerName,currentMoney) values (張三,1000)insert into bank(customerName,currentMoney) values (李四,1)select * fro
9、m bankcreate proc proc_banksend char(10),receive char(10),money moneyasbegindeclare xianyou moneyselect xianyou=currentMoney from bank where customerName=sendif(xianyou-money)0) begin begin tran fail update bank set currentMoney=currentMoney-money where customerName=send update bank set currentMoney
10、=currentMoney+money where customerName=receive print轉(zhuǎn)賬失?。?rollback tran fail endelse begin update bank set currentMoney=currentMoney-money where customerName=send update bank set currentMoney=currentMoney+money where customerName=receive print轉(zhuǎn)賬成功! endendexec proc_bank 張三,李四,500四、出現(xiàn)的的問題及解決方案1、問題:刪除用戶時提示異常。解決方案:在刪除用戶時,先刪除對應(yīng)的構(gòu)架,再刪除對應(yīng)的用戶。2、問題:操作不在對應(yīng)數(shù)據(jù)庫。解決方案:執(zhí)行代碼前,養(yǎng)成良好習(xí)慣,先使用use命令,切換到指定數(shù)據(jù)庫。3、問題:begin與end經(jīng)常沒有一一對應(yīng)。解決方案:在代碼排版上縮進一致,便
溫馨提示
- 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)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年渦轉(zhuǎn)浮動球閥項目投資價值分析報告
- 農(nóng)業(yè)產(chǎn)業(yè)發(fā)展趨勢與試題及答案
- 福建事業(yè)單位考試積極態(tài)度培養(yǎng)試題及答案
- 修車合伙協(xié)議合同樣本
- 2025至2030年油脂成套設(shè)備項目投資價值分析報告
- 2024年農(nóng)藝師考試的備考策略試題及答案
- 制定農(nóng)業(yè)發(fā)展戰(zhàn)略的必要性試題及答案
- 2025至2030年氣動式張網(wǎng)機項目投資價值分析報告
- 道橋巖土力學(xué)試題及答案
- 2025至2030年標(biāo)準(zhǔn)閃光銀白漿項目投資價值分析報告
- 深基坑開挖支護工程安全監(jiān)理實施細則
- YY/T 0606.3-2007組織工程醫(yī)療產(chǎn)品第3部分:通用分類
- 陜2022TJ 067 廚衛(wèi)裝配式鋼絲網(wǎng)混凝土排氣道系統(tǒng)建筑構(gòu)造圖集
- GB/T 21566-2008危險品爆炸品摩擦感度試驗方法
- GB/T 17207-2012電子設(shè)備用固定電容器第18-1部分:空白詳細規(guī)范表面安裝固體(MnO2)電解質(zhì)鋁固定電容器評定水平EZ
- 國開電大《人員招聘與培訓(xùn)實務(wù)》形考任務(wù)4國家開放大學(xué)試題答案
- 臨時用電現(xiàn)場安全檢查表
- 豬營養(yǎng)體系課件
- 青少年模擬法庭劇本(敲詐勒索)
- 中考復(fù)習(xí)確定二次函數(shù)的解析式課件
- 萬用表校準(zhǔn)報告
評論
0/150
提交評論