资源描述:
《数据库的数据类型(data type of database)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数据库的数据类型(Datatypeofdatabase)MySQLdatatypesandcolumntypes1.MySQLdatatypeThereareseveraldatatypesinmysql:(1)numericalValuesarevaluessuchas32or153.4.MySQLsupportsscientificnotation.Scientificnotationconsistsofintegersorfloatsfollowedby"e""Or"e",asymbol("+"or"-")andaninteg
2、erindex.Both1.24e+12and23.47e-1arelegitimatescientifictablesThenumberexpressedbyanotation.And1.24e12isnotlegalbecausetheindexbeforethesymbolisnotgivenAfloatingpointismadeupofanintegerpart,adecimalpoint,andadecimalpart.Theintegerpartandthefractionalpartcanbeempty,butnot
3、atthesametimeForempty.Thenumericalcanputaminussign"-"torepresentanegativevalue.(2)character(string)typeCharactertype(alsocalledstringtype,referredtoasstring)suchas"Hello,world!"or"causedbyaSteamedBunsofmurderthisvalue,Oravaluesuchasphonenumber87398413.Youcanencloseeith
4、erasinglequotationmarkoradoublequotationmarktoenclosethestringvalue.Beginnersoftencan'ttellthedifferencebetweenvalue87398143andstring87398143.It'sallnumbers.Howdoyouusenumericvalues?,Howaboutacharactertype?Thekeyis:thenumerical87398143istoparticipateinthecalculation,fo
5、rexample,itisatotalamountofmoneyinthefinance;Andcharactertype87398143isnotinvolvedinthecalculation,justthatthephonenumber,andsotherearestreetnumbers,housenumbers,andsoon,theyareallNotinvolvedincalculation.(3)dateandtimetype;Dateandtimearevaluessuchas"2006-07-12"or"12:3
6、0:43".MySQLalsosupportsacombinationofdate/time,Suchas"2006-07-1212:30:43"".(4)nullvalueNullrepresentsanunknownvalue.Forexample,fillintheaddressspaceisnotclearnotfillin,thisisthevalueofnull.WecreateatablewiththeCREATETABLEstatement(seetheprevioussection),whichcontainsth
7、edefinitionofcolumns.Forexample,wearethereAtablejokeiscreatedinfrontofwhichtherearetwocolumnscontentandwriter:Createtable(Contentvarchar(20)notnull,Writervarchar(10)null)Definethesyntaxofacolumnasfollows:Col_namecol_typy[col_attributes][general_attributes]Amongthem,col
8、umnnamesaregivenbycol_name.Columnnamescancontainupto64characters,includingletters,numbers,underscores,anddollarsymbol