资源描述:
《数据库系统概念全套配套课件PPT ch3.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter3:IntroductiontoSQLChapter3:IntroductiontoSQLOverviewoftheSQLQueryLanguageDataDefinitionBasicQueryStructureAdditionalBasicOperationsSetOperationsNullValuesAggregateFunctionsNestedSubqueriesModificationoftheDatabaseHistoryIBMSequellanguagedevelopedasparto
2、fSystemRprojectattheIBMSanJoseResearchLaboratoryRenamedStructuredQueryLanguage(SQL)ANSIandISOstandardSQL:SQL-86,SQL-89,SQL-92SQL:1999,SQL:2003,SQL:2008Commercialsystemsoffermost,ifnotall,SQL-92features,plusvaryingfeaturesetsfromlaterstandardsandspecialproprieta
3、ryfeatures.Notallexamplesheremayworkonyourparticularsystem.DataDefinitionLanguageTheschemaforeachrelation.Thedomainofvaluesassociatedwitheachattribute.IntegrityconstraintsAndaswewillseelater,alsootherinformationsuchasThesetofindicestobemaintainedforeachrelation
4、s.Securityandauthorizationinformationforeachrelation.Thephysicalstoragestructureofeachrelationondisk.TheSQLdata-definitionlanguage(DDL)allowsthespecificationofinformationaboutrelations,including:DomainTypesinSQLchar(n).Fixedlengthcharacterstring,withuser-specif
5、iedlengthn.varchar(n).Variablelengthcharacterstrings,withuser-specifiedmaximumlengthn.int.Integer(afinitesubsetoftheintegersthatismachine-dependent).smallint.Smallinteger(amachine-dependentsubsetoftheintegerdomaintype).numeric(p,d).Fixedpointnumber,withuser-spe
6、cifiedprecisionofpdigits,withndigitstotherightofdecimalpoint.real,doubleprecision.Floatingpointanddouble-precisionfloatingpointnumbers,withmachine-dependentprecision.float(n).Floatingpointnumber,withuser-specifiedprecisionofatleastndigits.MorearecoveredinChapte
7、r4.CreateTableConstructAnSQLrelationisdefinedusingthecreatetablecommand:createtabler(A1D1,A2D2,...,AnDn,(integrity-constraint1),...,(integrity-constraintk))risthenameoftherelationeachAiisanattributenameintheschemaofrelationrDiisthedatatypeofvaluesinthedomaino
8、fattributeAiExample:createtableinstructor(IDchar(5),namevarchar(20)notnull,dept_namevarchar(20),salarynumeric(8,2))insertintoinstructorvalues(‘10211’,’Smith’,’Biology’,66000