资源描述:
《数据库复习完整重难点》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、DatabaseManagementSystem(DBMS)asecuritysystem(authorizedusers)安全性anintegritysystem(consistencyofstoreddata)完整性aconcurrencycontrolsystem(sharedaccess)并发控制arecoverycontrolsystem(whenH/Sfailure)恢复auser-accessiblecatalog(descriptionsofdata)数据字典数据模型三要素Datastructure数据结构Datamanipulation数据操纵Con
2、straintsofdataintegrity数据的完整性约束EntityIntegrity实体完整性(Candidate)keysmustbeunique.码值唯一Inarelation,noattributeofaprimarykeycanbenull.基本表主码的诸属性均不能为空ReferentialIntegrity参照完整性外码取参照码值或取空值PRIMARYKEY(Book_Id),FOREIGNKEY(BorrowerMemNo)REFERENCESMEMBER(MemNo),INSERTINTOMEMBER(MemNo,Memname,PhoneNum
3、)VALUES(101,'SusanJones','412-376-8888');Divisionselectstheattributesspecifiedonanattribute_listfromatabler,whilediscardingtherest.Sixbasicoperators书名不会有两个Listthemembernumbersofalllibrarymemberwholikesallbookswrittenby‘Thomas’.Title(CallNumber,ISBN,Name,Author)Like(MemNo,CallNumber)(Lik
4、e)÷πCallNumberσAuthor=‘Thomas’(Title))SELECTMemNoFROMMemberMWHERENOTEXISTS((SELECTCallNumberFROMTitleWHEREAuthor='Thomas')EXCEPT(SELECTCallNumberFROMLikesLWHEREM.MemNo=L.MemNo));CharacterStringsFixedlengthnCHAR(n)orCHARACTER(n)定长串不足充空spaceVaryinglengthofmaximumnVARCHAR(n)orCHARVARYING(n
5、)变长串不足截断VARCHAR2(n)ORACLE用to_date('2013/03/08',‘yyyy/mm/dd')PRIMARYKEY(LIBSSN,Name),Theuniquekeywordspecifieseachrowmusthaveuniquevalues--specifythatasetofcolumnsmayserveasanalternatekey.备选码唯一码CREATETABLETitle(CallNumberVARCHAR(40),NameVARCHAR(200),ISBNVARCHAR(40),YearINT,PublisherVARCH
6、AR(80),PRIMARYKEY(CallNumber),UNIQUE(ISBN)//备选码备选码);DROPTABLEMEMBERCASCADE;DROPTABLEMEMBERRESTRICT;ALTERTABLEtable-nameALTER修改字段数据类型ALTERTABLELIBRARIANALTERSalaryNUMERIC(6,2);ALTERTABLELIBRARIANALTERCOLUMNSalaryTYPENUMERIC(6,2);--postgreSQLALTERTABLEtable-nameALTER修改字段数据类型ALTERTABLELIBR
7、ARIANALTERSalaryNUMBER(6,2);ALTERTABLELIBRARIANALTERCOLUMNSalaryTYPENUMBER(6,2);--postgreSQL改变字段的缺省值ALTERTABLEDEPENDENTALTERCOLUMNkinshipDROPDEFAULT;ALTERTABLEBOOKALTERCOLUMNBorrowerMemNoSETDEFAULTNULL;增加一个不能写成表约束的非空约束ALTERTABLEproductsALTERCOLUMNproduct_noSETNOTNULL;ALTERTABLE