欢迎来到天天文库
浏览记录
ID:49410409
大小:224.50 KB
页数:32页
时间:2020-02-06
《维护数据的完整性.ppt》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、维护数据的完整性目标学完这个课程,你应该可以掌握你下内容:实现数据完整性约束维护数据完整性约束从数据字典中获得完整性约束信息DataIntegrityApplicationcodeTableDataIntegrityconstraintDatabasetriggerTypesofConstraintsConstraintNOTNULLUNIQUEPRIMARYKEYFOREIGNKEYCHECKDescriptionSpecifiesthatacolumncannotcontainnullvaluesDesignat
2、esacolumnorcombinationofcolumnsasuniqueDesignatesacolumnorcombinationofcolumnsasthetable’sprimarykeyDesignatesacolumnorcombinationofcolumnsastheforeignkeyinareferentialintegrityconstraintSpecifiesaconditionthateachrowofthetablemustsatisfyConstraintStatesENABLE
3、NOVALIDATEExistingdataNewdataDISABLENOVALIDATEDISABLEVALIDATE==ENABLEVALIDATEConstraintCheckingDMLstatementChecknondeferredconstraintsCOMMITCheckdeferredconstraintsDefiningConstraintsImmediateorDeferredUsetheSETCONSTRAINTSstatementtomakeconstraintseitherDEFER
4、REDorIMMEDIATE.TheALTERSESSIONstatementalsohasclausestoSETCONSTRAINTStoDEFERREDorIMMEDIATE.PrimaryandUniqueKeyEnforcementIsanindexavailableforuse?YesNoNoYesYesNoCreatenonuniqueindexCreateuniqueindexDonotuseindexUseexistingindexKeyenabled?Constraintdeferrab
5、le?ConstraintDeferrable?Istheindexnonunique?YesNo/YesNoForeignKeyConsiderationsAppropriateSolutionDesiredActionDropparenttableCascadeconstraintsTruncateparenttableDisableordropforeignkeyPerformDMLonchildtableEnsurethatthetablespacecontainingtheparentkeyisonlineUse
6、theCASCADECONSTRAINTSclauseDroptablespacecontainingparenttableDefiningConstraintsWhileCreatingaTableCREATETABLEhr.employee(idNUMBER(7)CONSTRAINTemployee_id_pkPRIMARYKEYDEFERRABLEUSINGINDEXSTORAGE(INITIAL100KNEXT100K)TABLESPACEindx,last_nameVARCHAR2(25)CON
7、STRAINTemployee_last_name_nnNOTNULL,dept_idNUMBER(7))TABLESPACEusers;GuidelinesforDefiningConstraintsPrimaryanduniqueconstraints:Placeindexesinaseparatetablespace.Usenonuniqueindexesifbulkloadsarefrequent.Self-referencingforeignkeys:Defineorenableforeignkeysaftert
8、heinitialload.Deferconstraintchecking.EnablingConstraintsNolocksontablePrimaryanduniquekeysmustusenonuniqueindexesENABLENOVALIDATEALTERTABLEhr.departme
此文档下载收益归作者所有