版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、Chapter 7 Integrity, Views, Security, and Catalogs2022/7/18Integrity,Views,Security,and Catalogs2from Database Design to Physical FormCREATE TABLEintegrity constraints (完整性約束)CREATE VIEWSecurityThe GRANT & REVOKE statementsCatalogsSchemas2022/7/18Integrity,Views,Security,and Catalogs37.1 Integrity C
2、onstraintsDef.7.1.1 Clauses of the Create Table Command (Figure 7.1)schema name & table namecolumn defintioncolumn name & data typean optional DEFAULT clauseDEFAULT default_constant | NULL column constraintstable constraints2022/7/18Integrity,Views,Security,and Catalogs4Integrity Constraint (Figure
3、7.1, pg. 411)Integrity Constraints in a single column NOT NULL | CONSTRAINT constraint_name UNIQUE| PRIMARY KEY| CHECK ( search_condition )| REFERENCES table_name ( column_name ) ON DELETE CASCADE | RESTRICT | SET NULL ON UPDATE CASCADE | RESTRICT | SET NULL 2022/7/18Integrity,Views,Security,and Cat
4、alogs5Integrity Constraints in multiple columns CONSTRAINT constraint_name UNIQUE ( colname , colname . )| PRIMARY KEY ( colname , colname . )| CHECK ( search_condition )| FOREIGN KEY ( colname , colname . ) REFERENCES tab_name (colname , .) ON DELETE CASCADE|RESTRICT|SET NULLON UPDATE CASCADE|RESTR
5、ICT|SET NULL2022/7/18Integrity,Views,Security,and Catalogs67.1 Integrity ConstraintsTrigger (Figure 7.10, pg. 425) (觸發(fā)器)CREATE TRIGGER trigger_name BEFORE|AFTER INSERT | DELETE | UPDATE OF colname , colname . ON table_name REFERENCING corr_name_def , . FOR EACH ROW | FOR EACH STATEMENT WHEN ( search
6、_condition ) statement| BEGIN ATOMIC statement; . END7CREATE TRIGGER trigger_name BEFORE | AFTER INSERT | DELETE | UPDATE OF colname , colname . ON table_name REFERENCING corr_name_def , . FOR EACH ROW | FOR EACH STATEMENT WHEN ( search_condition ) statement| BEGIN ATOMIC statement; statement; . END
7、觸發(fā)事件結(jié)果事件觸發(fā)方式2022/7/18Integrity,Views,Security,and Catalogs87.2 Creating ViewsViewidea ?The data retrieved by any SQL SELECT statement is in the form of a table.We want to use this TABLE in FROM clause of other Select statement.Method?Subquery in the FROM clause (Fig 3.11)Creating Views2022/7/18Integ
8、rity,Views,Security,and Catalogs97.2 Creating ViewsView Table ( or View )DefinitionIt is a table that results from a subquery, but which has its own nametable name & attributes nameIt can be used in most ways as a Base Table created by SQL CREATE TABLE statement2022/7/18Integrity,Views,Security,and
9、Catalogs107.2 Creating ViewsView Table ( or View )Propertyno data storage in its own right, just window on data it selects fromso, it is regarded as a Virtual TableWeaknesslimits to View Updates2022/7/18Integrity,Views,Security,and Catalogs117.2 Creating ViewsUpdatable and Read-Only ViewsThe problem
10、How do we translate updates on the View into changes on the base tables?Figure 7.15Restrictions on the Subquery Clause for an Updatable View2022/7/18Integrity,Views,Security,and Catalogs12A view table is said to be updatable when the following conditions hold for its Subquery clause.The FROM clause
11、of the Subquery must contain only a single table, and if that table is a view table it must also be an updatable view table.Neither the GROUP BY nor HAVING clause is present.The DISTINCT keyword is not specified.The WHERE clause does not contain a Subquery that references any table in the FROM claus
12、e, directly or indirectly via views.All result columns of the Subquery are simple column names: no expressions, no column name appears more than once.2022/7/18Integrity,Views,Security,and Catalogs137.3 SecurityThe Grant Statement in SQLused by the owner of a tablethe owner of a table has ALL PRIVILE
13、GES on the table.other user can not access the table if it does not have the PRIVILEGES on the table.column privileges can be implemented through views.GRANT ALL PRIVILEGES|privilege , privilege ON TABLE tablename | viewnameTO PUBLIC | user-name , user-name WITH GRANT OPTION 2022/7/18Integrity,Views,Security,and Catalogs14The Grant Statement in SQL (cont.)privilegesSELECT, DELETE, INSER
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025版宿舍樓智能監(jiān)控設(shè)施承包合同3篇
- 2025年度木材貿(mào)易與木工加工合作合同4篇
- 夏令營2025非傳統(tǒng)教育項(xiàng)目合作合同3篇
- 2025年度木材加工廠設(shè)備租賃合同范本7篇
- 《漢服唯美古詩句》課件
- 2025版實(shí)習(xí)員工實(shí)習(xí)期間住宿安排合同3篇
- 養(yǎng)生保健與中醫(yī)養(yǎng)生藥物考核試卷
- 合成革表面處理與涂飾技術(shù)考核試卷
- 2025版智能電網(wǎng)信息安全防護(hù)合同4篇
- 創(chuàng)業(yè)空間科技創(chuàng)新平臺考核試卷
- 《天潤乳業(yè)營運(yùn)能力及風(fēng)險(xiǎn)管理問題及完善對策(7900字論文)》
- 醫(yī)院醫(yī)學(xué)倫理委員會章程
- xx單位政務(wù)云商用密碼應(yīng)用方案V2.0
- 農(nóng)民專業(yè)合作社財(cái)務(wù)報(bào)表(三張報(bào)表)
- 動(dòng)土作業(yè)專項(xiàng)安全培訓(xùn)考試試題(帶答案)
- 大學(xué)生就業(yè)指導(dǎo)(高職就業(yè)指導(dǎo)課程 )全套教學(xué)課件
- 死亡病例討論總結(jié)分析
- 第二章 會展的產(chǎn)生與發(fā)展
- 空域規(guī)劃與管理V2.0
- JGT266-2011 泡沫混凝土標(biāo)準(zhǔn)規(guī)范
- 商戶用電申請表
評論
0/150
提交評論