Membuat Database di MySQL

  Me m b ua t Da ta b a se d i MySQ L

  Da ta b a se MySQ L b e rikut ini d ib ua t d e ng a n p ro g ra m Xa m p , jika me ng g una ka n p ro g ra m MySQ L la inya p a d a umumnya ha m p ir sa m a , p e rb e d a a n ha nya p a d a p o sisi d a n ta m p ila nya sa ja . Ma ka untuk p ro g ra m se la in Xa m p p d ise sua ika n.

  9 Ja la nka n Pro g ra m Ap a c he d a n MySQ lnya

  9 Buka Inte rne t e xp lo re r a ta u p ro g ra m b ro wse r la innya

  9 Ke tik d i a la m a tnya / a d d re ss : http :/ / lo c a lho st/ p hp m ya d m in/ 9 c re a te ne w da ta b a se

  Bua t na ma d a ta b a se d i , la lu klik to mb o l Cre a te (d ib a w a h ini me ng g una ka n p ro g ra m Xa m p p ) Ad a b e b e ra p a Ta b ya ng a d a p a d a MySQ L Xa m p p

  Strukture - Pa d a ta b ini te rd a p a t ta b le ya ng te la h d ib ua t p a d a d a ta b a se , d a n te mp a t untuk me m b ua t ta b le b a ru.

  • SQ L Pa d a Ta b SQ L, te rd a p a t te mp a t untuk me m a sukka n p ro g ra m SQ L Se a rc h - Fung si Se a rc h a d a la h te mp a t me nc a ri d a ta ya ng sud a h p e rna h d isimp a n d a la m ta b le a ta u d a ta b a se
  • Q ue ry

  Ta b ini untuk me m b ua t Q ue ry p a d a Da ta b a se

  • Exp o rt
  • Im p o rt
  • O p e ra tio ns

  Me ro b a h a ta u me nyim p a n file d a ta b a se ke d a la m b e ntuk file te rte ntu a ta u untuk me mb a c kup d a ta b a se

  Me m a ng g il d a ta b a se ya ng p e rna h d isim p a n untuk d im a sukka n ke d a la m d a ta b a se m ysq l ya ng d iing inka n

  Pa d a ta b o p e ra tio n te rd a p a t b e b e ra p a o p e ra si ya ng d a p a t d ila kuka n p a d a d a ta b a se se p e rti : me m b ua t ta b le b a ru, me m b ua t c o m me nt d a ta b a se , m e ng g a nti na m a d a ta b a se , d a n m e ng c o p y d a ta b a se .

  • Privile g e s
  • Dro p
  • Klik p a d a ta b Strukture - Bua t na ma ta b le ya ng a ka n a nd a b ua t p a d a na me d i Cre a te ne w ta b le o n
  • Bua t na ma m a sing – m a sing fie ld / ko lo m d a ri ta b le ya ng a ka n d ib ua t, d iko lo m fie ld . Pilih Tip e d a ri fie ld te rse b ut d i typ e , isi p a nja ng ka ra kte r d i Le ng th/va lue s (ke c ua li d a te , d a te time , tim e ).
  • Pilih o p tio n

  Te m p a t info rm a si use r ya ng d a p a t m e ng a kse s d a ta b a se

  Ta b untuk m e ng ha p us d a ta b a se ya ng a d a

  a . Me m b ua t ta np a p ro g ra m m ysq l, c a ra nya :

  da ta b a se ….,

  d a n jum la h ko lo m p a d a ta b le te rse b ut d i

  Numb e r o f fie lds

  , d a n klik to mb o l Go

  p rima ry ke y

  jika fie ld te rse b ut p rim a ry Uniq ue Prim a ry ke y

  Full Te xt Ind e x

  Klik to mb o l sa ve untuk me nyim p a n. - To m b o l Bro wse I - untuk me liha t d a ta ya ng d isim p a n, to m b o l Cha ng e untuk me ng g a nti d a ta d a ri fie ld ya ng te la h d iinp utka n se b e lum nya , d a n d ro p untuk me ng ha p us fie ld ya ng sa la h

  Bro wse C ha ng e

  Ind e x Uniq ue

  Dro p Prim a ry ke y

  • Jika a ka n me na m b a h fie ld , m a ka isika n b a nya k fie ld ya ng a ka n d ita m b a h p a d a ko lo m Add , p ilih p o sisinya d im a na (d ia khir ta b le , d ia w a l ta b le a ta u

  Go

  se te la h fie ld te rte ntu). Da n klik to m b o l

  dro p

  Untuk me ng ha p us p rim a ry klik to m b o l ,p a d a ta b le p rim a ry d a n untuk - me ng e d it m a ka klik to mb o l c ha ng e

  b . Me m b ua t d e ng a n p ro g ra m m ysq l c a ra nya :

  Pilih ta b SQ L -

  • ke tik p ro g ra m m ysq l d ite m p a t Run SQl q ue ry/q ue rie s o n da ta b a se d a n klik to mb o l Go .

  c .

  Me m b ua t ta b le mysq l d e ng a n file ya ng te la h d isimp a n se b e lumnya , d ib ua t d i no te p a d a ta u d ib ua t d e ng a n p ro g ra m la innya . C a ra nya :

  • Pilih ta b Imp o rt

  Bro wse

  Klik to mb o l ke m ud ia n p ilih file ya ng d isim p a n te rse b ut - Klik To mb o l Go -

Me nyimp a n Da ta b a se MySQ L

  Da ta b a se ya ng te la h d ib ua t d i m ysq l se sua i d e ng a n c a ra ya ng d ia ta s, se b e na rnya sud a h te rsim p a n te mp a t la in p e rlu d ila kuka n Ba c kup d a ta b a se . Ad a p un c a ra nya se b a g a i b e rikut :

  1. Pilih ta b Exp o rt m a ka a ka n ta mp il fo rm e xp o rt se p e rti b e rikut :

  2. Pilih b e ntuk file ya ng a ka n d isim p a n se p e rti SQ L, La te x, p d f, d ll (a g a r d a p a t d iImp o rt la g i p a d a Mysq l se b a iknya p ilih SQ L)

  3. C he c k list p a d a Struktur d a n p a d a Da ta se sua i ya ng ing in d isim p a n (jika ing in sa m a p e rsis d e ng a n ya ng a slinya c he c k list se mua nya p a d a Struktur d a n Da ta

  4. C he c k list Sa ve a s file d a n ma sukka n na m a file p a d a File na me te mp la te

  5. Go

  Klik To mb o l Me ng e na l Typ e Da ta MySQ L Sumb e r : http :/ / d e v.mysq l.c o m/ d o c / re fma n/ 5.0/ e n/ d a ta -typ e -o ve rvie w.html

Nume ric Type s

  9 BIT[( M )]

  A b it-fie ld typ e . M ind ic a te s the numb e r o f b its p e r va lue , fro m 1 to 64. The d e fa ult is 1 if M is o m itte d .This d a ta typ e w a s a d d e d in MySQ L 5.0.3 fo r MyISAM, a nd e xte nd e d in 5.0.5 to MEMO RY, Inno DB, BDB, a nd NDBC LUSTER. Be fo re 5.0.3, BIT is a syno nym fo r TINYINT(1).

  9 TINYINT[( M )] [UNSIG NED] [ZERO FILL]

  A ve ry sm a ll inte g e r. The sig ne d ra ng e is -128 to 127. The unsig ne d ra ng e is 0 to 255. BO O L, BO O LEAN The se typ e s a re syno nyms fo r TINYINT(1). A va lue o f ze ro is c o nsid e re d fa lse . No n-ze ro va lue s a re c o nsid e re d true : o we ve r, the va lue s TRUE a nd FALSE a re me re ly a lia se s fo r 1 a nd 0, re sp e c tive ly. The la st two sta te m e nts d isp la y the re sults sho wn b e c a use 2 is e q ua l to ne ithe r 1 no r 0. We inte nd to im p le me nt full b o o le a n typ e ha nd ling , in a c c o rd a nc e with sta nd a rd SQ L, in a future MySQ L re le a se .

  9 SMALLINT[( M )] [UNSIG NED] [ZERO FILL]

  A sm a ll inte g e r. The sig ne d ra ng e is -32768 to 32767. The unsig ne d ra ng e is 0 to 65535.

  9 MEDIUMINT[( M )] [UNSIG NED] [ZERO FILL]

  A me d ium -size d inte g e r. The sig ne d ra ng e is -8388608 to 8388607. The unsig ne d ra ng e is 0 to 16777215.

  9 M

  INT[( )] [UNSIG NED] [ZERO FILL] A no rm a l-size inte g e r. The sig ne d ra ng e is -2147483648 to 2147483647. The unsig ne d ra ng e is 0 to 4294967295.

  9 INTEG ER[( M )] [UNSIG NED] [ZERO FILL]

  This typ e is a syno nym fo r INT .

  9 M

  BIG INT[( )] [UNSIG NED] [ZERO FILL] A la rg e inte g e r. The sig ne d ra ng e is -9223372036854775808 to 9223372036854775807. The unsig ne d ra ng e is 0 to 18446744073709551615. SERIAL is a n a lia s fo r BIG INT UNSIG NED NO T NULL AUTO _INC REMENT UNIQ UE. So m e thing s yo u sho uld b e a w a re o f with re sp e c t to BIG INT c o lumns:

  • All a rithme tic is d o ne using sig ne d BIG INT o r DO UBLE va lue s, so yo u sho uld no t use unsig ne d b ig inte g e rs la rg e r tha n 9223372036854775807 (63 b its) e xc e p t w ith b it func tio ns! If yo u d o tha t, so me o f the la st d ig its in the re sult m a y b e wro ng b e c a use o f ro und ing e rro rs whe n c o nve rting a BIG INT va lue to a DO UBLE . MySQ L c a n ha nd le BIG INT in the fo llo w ing c a se s: o

  Whe n using inte g e rs to sto re la rg e unsig ne d va lue s in a BIG INT o c o lumn.

  MIN( c o l_na me ) o r MAX( c o l_na me ) , whe re c o l_na me re fe rs to

  In a BIG INT c o lumn. o Whe n using o p e ra to rs ( , + , * , a nd so o n) whe re b o th o p e ra nd s

  • -

    a re inte g e rs.

  BIG INT c o lumn b y

  sto ring it using a string . In this c a se , MySQ L p e rfo rms a string -to -num b e r c o nve rsio n tha t invo lve s no inte rme d ia te d o ub le -p re c isio n re p re se nta tio n.

  • o p e ra to rs use BIG INT a rithm e tic whe n b o th o p e ra nd s a re + , , a nd
    • The inte g e r va lue s. This me a ns tha t if yo u multip ly two b ig inte g e rs (o r re sults fro m func tio ns tha t re turn inte g e rs), yo u m a y g e t une xp e c te d re sults w he n the re sult is la rg e r tha n 9223372036854775807.

  9 FLO AT[( M , D )] [UNSIG NED] [ZERO FILL]

  A sm a ll (sing le -p re c isio n) flo a ting -p o int num b e r. Allo wa b le va lue s a re - 3.402823466E+38 to -1.175494351E-38, 0, a nd 1.175494351E-38 to 3.402823466E+38. The se a re the the o re tic a l limits, b a se d o n the IEEE sta nd a rd .

  The a c tua l ra ng e m ig ht b e slig htly sm a lle r d e p e nd ing o n yo ur ha rd w a re o r

  M D

  o p e ra ting syste m. is the to ta l numb e r o f d ig its a nd is the num b e r o f d ig its fo llo w ing the d e c im a l p o int. If M a nd D a re o m itte d , va lue s a re sto re d to the lim its a llo we d b y the ha rd w a re . A sing le -p re c isio n flo a ting -p o int numb e r is a c c ura te to a p p ro xim a te ly 7 d e c ima l p la c e s. UNSIG NED, if sp e c ifie d , d isa llo w s ne g a tive va lue s. Using FLO AT m ig ht g ive yo u so m e une xp e c te d p ro b le m s b e c a use a ll c a lc ula tio ns in MySQ L a re d o ne with d o ub le p re c isio n.

  9 M D

  DO UBLE[( , )] [UNSIG NED] [ZERO FILL] A no rma l-size (d o ub le -p re c isio n) flo a ting -p o int num b e r. Allo wa b le va lue s a re - 1.7976931348623157E+308 to -2.2250738585072014E-308, 0, a nd 2.2250738585072014E-308 to 1.7976931348623157E+308. The se a re the the o re tic a l lim its, b a se d o n the IEEE sta nd a rd . The a c tua l ra ng e m ig ht b e slig htly sm a lle r d e p e nd ing o n yo ur ha rd w a re o r o p e ra ting syste m . M is the to ta l numb e r o f d ig its a nd D is the num b e r o f d ig its fo llo wing the d e c im a l p o int. If M a nd D a re o m itte d , va lue s a re sto re d to the lim its a llo we d b y the ha rd wa re . A d o ub le - p re c isio n flo a ting -p o int numb e r is a c c ura te to a p p ro xim a te ly 15 d e c ima l p la c e s. UNSIG NED, if sp e c ifie d , d isa llo w s ne g a tive va lue s.

  9 DO UBLE PREC ISIO N[( M , D )] [UNSIG NED] [ZERO FILL], REAL[( M , D )] [UNSIG NED]

  [ZERO FILL] The se typ e s a re syno nym s fo r DO UBLE . Exc e p tio n: If the REAL_AS_FLO AT SQ L mo d e is e na b le d , REAL is a syno nym fo r FLO AT ra the r tha n DO UBLE .

  9 FLO AT( p ) [UNSIG NED] [ZERO FILL]

  A flo a ting -p o int numb e r. p re p re se nts the p re c isio n in b its, b ut MySQ L use s this va lue o nly to d e te rmine whe the r to use FLO AT o r DO UBLE fo r the re sulting d a ta typ e . If p is fro m 0 to 24, the d a ta typ e b e c o me s FLO AT w ith no M o r D va lue s. If p is fro m 25 to 53, the d a ta typ e b e c o me s DO UBLE w ith no M o r D va lue s. The ra ng e o f the re sulting c o lum n is the sa m e a s fo r the sing le - p re c isio n FLO AT o r d o ub le -p re c isio n DO UBLE d a ta typ e s d e sc rib e d e a rlie r in this se c tio n. FLO AT( p ) synta x is p ro vid e d fo r O DBC c o mp a tib ility.

  9 DEC IMAL[( M [, D ])] [UNSIG NED] [ZERO FILL]

  Fo r MySQ L 5.0.3 a nd a b o ve :

  M

  A p a c ke d “ e xa c t” fixe d -p o int numb e r. is the to ta l num b e r o f d ig its (the p re c isio n) a nd D is the numb e r o f d ig its a fte r the d e c im a l p o int (the sc a le ). The d e c im a l p o int a nd (fo r ne g a tive num b e rs) the “ -” sig n a re no t c o unte d in

  M D

  . If is 0, va lue s ha ve no d e c im a l p o int o r fra c tio na l p a rt. The m a ximum

  M

  num b e r o f d ig its ( ) fo r DEC IMAL is 65 (64 fro m 5.0.3 to 5.0.5). The m a ximum numb e r o f sup p o rte d d e c im a ls ( D ) is 30. If D is o mitte d , the d e fa ult is 0. If M is o m itte d , the d e fa ult is 10. UNSIG NED, if sp e c ifie d , d isa llo w s ne g a tive va lue s. All b a sic c a lc ula tio ns (+, -, *, / ) with DEC IMAL c o lumns a re d o ne w ith a p re c isio n o f 65 d ig its. Be fo re MySQ L 5.0.3: An unp a c ke d fixe d -p o int numb e r. Be ha ve s like a C HAR c o lumn; “ unp a c ke d ” me a ns the num b e r is sto re d a s a string , using o ne c ha ra c te r fo r e a c h d ig it o f the va lue . M is the to ta l numb e r o f d ig its a nd D is the numb e r o f d ig its a fte r the d e c im a l p o int. The d e c ima l p o int a nd (fo r ne g a tive numb e rs) the “ -” sig n

  M D

  a re no t c o unte d in , a ltho ug h sp a c e fo r the m is re se rve d . If is 0, va lue s ha ve no d e c im a l p o int o r fra c tio na l p a rt. The m a xim um ra ng e o f DEC IMAL va lue s is the sa me a s fo r DO UBLE , b ut the a c tua l ra ng e fo r a g ive n DEC IMAL

  M D D

  c o lumn m a y b e c o nstra ine d b y the c ho ic e o f a nd . If is o mitte d , the

  M

  d e fa ult is 0. If is o m itte d , the d e fa ult is 10. UNSIG NED, if sp e c ifie d , d isa llo ws ne g a tive va lue s.

  The b e ha vio r use d b y the se rve r fo r DEC IMAL c o lumns in a ta b le d e p e nd s o n the ve rsio n o f MySQ L use d to c re a te the ta b le . If yo ur se rve r is fro m MySQ L 5.0.3 o r hig he r, b ut yo u ha ve DEC IMAL c o lumns in ta b le s tha t we re c re a te d b e fo re 5.0.3, the o ld b e ha vio r still a p p lie s to tho se c o lumns. To c o nve rt the ta b le s to the ne w e r DEC IMAL fo rm a t, d um p the m with mysqldump a nd re lo a d the m .

  M D

  [ZERO FILL], FIXED[( [, ])] [UNSIG NED] [ZERO FILL] The se typ e s a re syno nym s fo r DEC IMAL . The FIXED syno nym is a va ila b le fo r c o m p a tib ility w ith o the r d a ta b a se syste ms.

  Da te a nd Time Typ e s ™

  DATE

  A d a te . The sup p o rte d ra ng e is '1000-01-01' to '9999-12-31'. MySQ L d isp la ys

  DATE va lue s in 'YYYY-MM-DD' fo rma t, b ut a llo ws a ssig nm e nt o f va lue s to DATE c o lum ns using e ithe r string s o r num b e rs.

  ™ DATETIME

  A d a te a nd time c o m b ina tio n. The sup p o rte d ra ng e is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. MySQ L d isp la ys DATETIME va lue s in 'YYYY-MM-DD HH:MM:SS' fo rma t, b ut a llo ws a ssig nme nt o f va lue s to DATETIME c o lumns using e ithe r string s o r num b e rs.

  ™ TIMESTAMP

  A time sta m p . The ra ng e is '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC . TIMESTAMP va lue s a re sto re d a s the num b e r o f se c o nd s sinc e the e p o c h ('1970-01-01 00:00:00' UTC ). A TIMESTAMP c a nno t re p re se nt the va lue '1970-01- 01 00:00:00' b e c a use tha t is e q uiva le nt to 0 se c o nd s fro m the e p o c h a nd the va lue 0 is re se rve d fo r re p re se nting '0000-00-00 00:00:00', the “ ze ro ” TIMESTAMP va lue .

  A TIMESTAMP c o lumn is use ful fo r re c o rd ing the d a te a nd time o f a n

  INSERT o r UPDATE o p e ra tio n. By d e fa ult, the first TIMESTAMP c o lumn in a ta b le is

  a uto m a tic a lly se t to the d a te a nd time o f the mo st re c e nt o p e ra tio n if yo u d o no t a ssig n it a va lue yo urse lf. Yo u c a n a lso se t a ny TIMESTAMP c o lumn to the c urre nt d a te a nd tim e b y a ssig ning it a NULL va lue . Va ria tio ns o n a uto m a tic initia liza tio n a nd up d a te p ro p e rtie s a re d e sc rib e d in Se c tio n 10.3.1.1,

  “ TIMESTAMP Pro p e rtie s” .

  A TIMESTAMP va lue is re turne d a s a string in the fo rm a t 'YYYY-MM-DD HH:MM:SS' with a d isp la y wid th fixe d a t 19 c ha ra c te rs. To o b ta in the va lue a s a num b e r, yo u sho uld a d d +0 to the time sta m p c o lumn.

  Note

  The TIMESTAMP fo rm a t tha t w a s use d p rio r to MySQ L 4.1 is no t sup p o rte d in

  MySQL 3.23, 4.0, 4.1 Re fe re nc e Ma nua l

  MySQ L 5.0; se e fo r info rm a tio n re g a rd ing the o ld fo rm a t.

  ™ TIME

  A time . The ra ng e is '-838:59:59' to '838:59:59'. MySQ L d isp la ys TIME va lue s in 'HH:MM:SS' fo rm a t, b ut a llo ws a ssig nm e nt o f va lue s to TIME c o lumns using e ithe r string s o r num b e rs.

  ™

  YEAR[(2| 4)] A ye a r in tw o -d ig it o r fo ur-d ig it fo rm a t. The d e fa ult is fo ur-d ig it fo rma t. In fo ur- d ig it fo rm a t, the a llo w a b le va lue s a re 1901 to 2155, a nd 0000. In two -d ig it fo rm a t, the a llo wa b le va lue s a re 70 to 69, re p re se nting ye a rs fro m 1970 to va lue s to YEAR c o lum ns using e ithe r string s o r num b e rs.

  String Typ e s ¾

  [NATIO NAL] C HAR[( M )] [C HARAC TER SET c ha rse t_na me ] [C O LLATE

  c o lla tio n_na me ]

  A fixe d -le ng th string tha t is a lw a ys rig ht-p a d d e d w ith sp a c e s to the sp e c ifie d

  M

  le ng th whe n sto re d . re p re se nts the c o lum n le ng th in c ha ra c te rs. The ra ng e o f M is 0 to 255. If M is o mitte d , the le ng th is 1.

  ¾

  [NATIO NAL] VARC HAR( M ) [C HARAC TER SET c ha rse t_na me ] [C O LLATE

  c o lla tio n_na me ] M

  A va ria b le -le ng th string . re p re se nts the m a xim um c o lum n le ng th in c ha ra c te rs. In MySQ L 5.0, the ra ng e o f M is 0 to 255 b e fo re MySQ L 5.0.3, a nd 0 to 65,535 in MySQ L 5.0.3 a nd la te r. The e ffe c tive m a ximum le ng th o f a

  VARC HAR in MySQ L 5.0.3 a nd la te r is sub je c t to the ma ximum ro w size (65,535

  b yte s, w hic h is sha re d a mo ng a ll c o lumns) a nd the c ha ra c te r se t use d . Fo r e xa m p le , utf8 c ha ra c te rs c a n re q uire up to thre e b yte s p e r c ha ra c te r, so a

  VARC HAR c o lumn tha t use s the utf8 c ha ra c te r se t c a n b e d e c la re d to b e a ma ximum o f 21,844 c ha ra c te rs.

  MySQ L sto re s

  VARC HAR va lue s a s a o ne -b yte o r two -b yte le ng th p re fix p lus

  d a ta . The le ng th p re fix ind ic a te s the num b e r o f b yte s in the va lue . A

  VARC HAR c o lum n use s o ne le ng th b yte if va lue s re q uire no m o re tha n 255 b yte s, two le ng th b yte s if va lue s m a y re q uire mo re tha n 255 b yte s.

  ¾

  BINARY( M ) The BINARY typ e is sim ila r to the C HAR typ e , b ut sto re s b ina ry b yte string s ra the r tha n no n-b ina ry c ha ra c te r string s. M re p re se nts the c o lum n le ng th in b yte s.

  ¾

  VARBINARY( M ) The

  VARBINARY typ e is sim ila r to the

  VARC HAR typ e , b ut sto re s b ina ry b yte

  string s ra the r tha n no n-b ina ry c ha ra c te r string s. M re p re se nts the m a ximum c o lumn le ng th in b yte s.

  ¾ TINYBLO B 8 A BLO B c o lumn w ith a m a ximum le ng th o f 255 (2 – 1) b yte s. Ea c h TINYBLO B

  va lue is sto re d using a o ne -b yte le ng th p re fix tha t ind ic a te s the num b e r o f b yte s in the va lue . TINYTEXT [C HARAC TER SET ] [C O LLATE ] 8 A TEXT c o lumn w ith a m a ximum le ng th o f 255 (2 – 1) c ha ra c te rs. The e ffe c tive ma ximum le ng th is le ss if the va lue c o nta ins multi-b yte c ha ra c te rs. Ea c h

  TINYTEXT va lue is sto re d using a o ne -b yte le ng th p re fix tha t ind ic a te s the numb e r o f b yte s in the va lue .

  ¾

  BLO B[( M )] 16 A BLO B c o lumn with a m a ximum le ng th o f 65,535 (2 – 1) b yte s. Ea c h BLO B va lue is sto re d using a tw o -b yte le ng th p re fix tha t ind ic a te s the numb e r o f b yte s in the va lue .

  M

  An o p tio na l le ng th c a n b e g ive n fo r this typ e . If this is d o ne , MySQ L c re a te s the c o lumn a s the sma lle st BLO B typ e la rg e e no ug h to ho ld va lue s M b yte s lo ng .

  ¾ M c ha rse t_na me c o lla tio n_na me

  TEXT[( )] [C HARAC TER SET ] [C O LLATE ] 16 A TEXT c o lumn with a m a ximum le ng th o f 65,535 (2 – 1) c ha ra c te rs. The e ffe c tive m a ximum le ng th is le ss if the va lue c o nta ins multi-b yte c ha ra c te rs.

  Ea c h TEXT va lue is sto re d using a tw o -b yte le ng th p re fix tha t ind ic a te s the numb e r o f b yte s in the va lue .

  M

  An o p tio na l le ng th c a n b e g ive n fo r this typ e . If this is d o ne , MySQ L c re a te s the c o lumn a s the sm a lle st TEXT typ e la rg e e no ug h to ho ld va lue s M c ha ra c te rs lo ng .

  ¾ MEDIUMBLO B 24 A BLO B c o lumn with a m a ximum le ng th o f 16,777,215 (2 – 1) b yte s. Ea c h MEDIUMBLO B va lue is sto re d using a thre e -b yte le ng th p re fix tha t ind ic a te s the

  numb e r o f b yte s in the va lue .

  ¾

  MEDIUMTEXT [C HARAC TER SET c ha rse t_na me ] [C O LLATE c o lla tio n_na me ] 24 A TEXT c o lumn w ith a m a ximum le ng th o f 16,777,215 (2 – 1) c ha ra c te rs. The e ffe c tive m a ximum le ng th is le ss if the va lue c o nta ins multi-b yte c ha ra c te rs.

  Ea c h MEDIUMTEXT va lue is sto re d using a thre e -b yte le ng th p re fix tha t ind ic a te s the numb e r o f b yte s in the va lue .

  ¾ LO NG BLO B 32 A BLO B c o lumn w ith a m a ximum le ng th o f 4,294,967,295 o r 4G B (2 – 1) b yte s.

  The e ffe c tive m a xim um le ng th o f LO NG BLO B c o lum ns d e p e nd s o n the c o nfig ure d m a ximum p a c ke t size in the c lie nt/ se rve r p ro to c o l a nd a va ila b le me mo ry. Ea c h LO NG BLO B va lue is sto re d using a fo ur-b yte le ng th p re fix tha t ind ic a te s the numb e r o f b yte s in the va lue .

  ¾

  LO NG TEXT [C HARAC TER SET c ha rse t_na me ] [C O LLATE c o lla tio n_na me ] 32 A TEXT c o lumn w ith a m a ximum le ng th o f 4,294,967,295 o r 4G B (2 – 1) c ha ra c te rs. The e ffe c tive m a xim um le ng th is le ss if the va lue c o nta ins multi- b yte c ha ra c te rs. The e ffe c tive m a xim um le ng th o f LO NG TEXT c o lum ns a lso d e p e nd s o n the c o nfig ure d m a xim um p a c ke t size in the c lie nt/ se rve r p ro to c o l a nd a va ila b le me mo ry. Ea c h LO NG TEXT va lue is sto re d using a fo ur-b yte le ng th p re fix tha t ind ic a te s the num b e r o f b yte s in the va lue .

  ¾

  ENUM(' va lue 1 ',' va lue 2 ',...) [C HARAC TER SET c ha rse t_na me ] [C O LLATE

  c o lla tio n_na me ]

  An e nume ra tio n. A string o b je c t tha t c a n ha ve o nly o ne va lue , c ho se n fro m the list o f va lue s ' va lue 1 ', ' va lue 2 ', ..., NULL o r the sp e c ia l '' e rro r va lue . An

  ENUM c o lumn c a n ha ve a ma ximum o f 65,535 d istinc t va lue s. ENUM va lue s a re re p re se nte d inte rna lly a s inte g e rs.

  ¾ va lue 1 va lue 2 c ha rse t_na me

  SET(' ',' ',...) [C HARAC TER SET ] [C O LLATE

  c o lla tio n_na me ]

  A se t. A string o b je c t tha t c a n ha ve ze ro o r m o re va lue s, e a c h o f whic h m ust

  va lue 1 va lue 2

  b e c ho se n fro m the list o f va lue s ' ', ' ', ... A SET c o lumn c a n ha ve a ma ximum o f 64 me m b e rs. SET va lue s a re re p re se nte d inte rna lly a s inte g e rs. Da ta Typ e De fa ult Va lue s

  • Fo r nume ric typ e s, the d e fa ult is 0, with the e xc e p tio n tha t fo r inte g e r o r flo a ting -p o int typ e s d e c la re d w ith the AUTO _INC REMENT a ttrib ute , the d e fa ult is the ne xt va lue in the se q ue nc e .

  TIMESTAMP , the d e fa ult is the a p p ro p ria te

  • Fo r d a te a nd time typ e s o the r tha n

  “ ze ro ” va lue fo r the typ e . Fo r the first TIMESTAMP c o lum n in a ta b le , the d e fa ult va lue is the c urre nt d a te a nd tim e . Se e Se c tio n 10.3, “ Da te a nd Time

  Typ e s” .

  ENUM , the d e fa ult va lue is the e m p ty string . Fo r

  • Fo r string typ e s o the r tha n ENUM , the d e fa ult is the first e num e ra tio n va lue .