PART2RELATIONALDATABASESChapter4AdvancedSQLMarch2009DatabaseSystemConcepts-Chapter4AdvancedSQL-3IntegrityconstraintsinSQL§4.1-4.2SecurityinSQL(§4.3)authorization,grant/revokeEmbeddedanddynamicSQL§4.4-4.5ThreePartsinChapter4March2009DatabaseSystemConcepts-Chapter4AdvancedSQL-4CasestudyusedinthischapterreturnThreePartsinChapter4(cont.)March2009DatabaseSystemConcepts-Chapter4AdvancedSQL-54.1.1Built-inDataTypesinSQLInadditiontothebasicdatatypes,e.g.char(n),varchar(n),int,smallint,numeric(p,d),real,doubleprecision,float(n),describedin§3.2,theotherbuilt-indatatypesincludedate:Dates,containinga(4digit)year,monthanddatee.g.date‘2005-7-27time:Timeofday,inhours,minutesandsecondse.g.time‘09:00:30.75timestamp:dateplustimeofdaye.g.timestamp‘2005-7-2709:00:30.75’interval:periodoftimee.g.interval‘1’day§4.1SQLDataTypesandSchemasMarch2009DatabaseSystemConcepts-Chapter4AdvancedSQL-6Subtractingadate/time/timestampvaluefromanothergivesanintervalvalueintervalvaluescanbeaddedtodate/time/timestampvaluesValuesofindividualfieldscanbeextractedfromdate/time/timestampe.g.extract(yearfromr.starttime)Wecancast/convertstringtypestodate/time/timestampe.g.castasdatee.g.castastime4.1.1Built-inDataTypesinSQL(cont.)March2009DatabaseSystemConcepts-Chapter4AdvancedSQL-7Thecreatetypeclausecanbeusedtodefinenewuser-definedtypese.g.createtypeDollarsasnumeric(12,2)finalThecreatedomainclausecanbeusedtodefinenewuser-defineddomainse.g.createdomainperson_namechar(20)notnull4.1.2User-definedTypesMarch2009DatabaseSystemConcepts-Chapter4AdvancedSQL-84.1.3Large-ObjectTypesLargeobjects(photos,videos,CADfiles,etc.)arestoredasalargeobjectblob:binarylargeobjecttheobjectisalargecollectionofuninterpretedbinarydata,whoseinterpretationislefttoanapplicationoutsideofthedatabasesystemclob:characterlargeobjecttheobjectisalargecollectionofcharacterdataWhenaqueryreturnsalargeobject,apointerisreturned...