13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

240 Chapter 9 Creating Your <strong>Web</strong> Database<br />

In practice, BLOB <strong>and</strong> TEXT columns are the same except that BLOB is case sensitive<br />

<strong>and</strong> TEXT is not. Because these column types can hold large amounts of data, they<br />

require some special considerations.We discuss this issue in Chapter 12.<br />

The third group has two special types: SET <strong>and</strong> ENUM.The SET type specifies that values<br />

in this column must come from a particular set of specified values. Column values<br />

can contain more than one value from the set.You can have a maximum of 64 things in<br />

the specified set.<br />

ENUM is an enumeration. It is very similar to SET, except that columns of this type can<br />

have only one of the specified values or NULL, <strong>and</strong> you can have a maximum of 65,535<br />

things in the enumeration.<br />

We summarized the string data types in Tables 9.9, 9.10, <strong>and</strong> 9.11.Table 9.9 shows the<br />

plain string types.<br />

Table 9.9 Regular String Types<br />

Type Range Description<br />

[NATIONAL] 0 to 255 Fixed-length string of length<br />

CHAR(M) characters M, where M is between 0 <strong>and</strong><br />

[BINARY | ASCII | UNICODE]<br />

255.The NATIONAL keyword<br />

specifies that the default<br />

character set should be used.<br />

This is the default in <strong>MySQL</strong><br />

anyway, but is included because it<br />

is part of the ANSI SQL st<strong>and</strong>ard.<br />

The BINARY keyword specifies that<br />

the data should be treated as case<br />

sensitive. (The default is case<br />

sensitive.) The ASCII keyword<br />

specifies that the latin1 character<br />

set will be used for this column.The<br />

UNICODE keyword specifies that<br />

the ucs character set will be used.<br />

CHAR<br />

Synonym for CHAR(1).<br />

[NATIONAL] VARCHAR(M) 1 to 255 Same as above, except they are<br />

[BINARY] characters variable length.<br />

Table 9.10 shows the TEXT <strong>and</strong> BLOB types.The maximum length of a TEXT field in characters<br />

is the maximum size in bytes of files that could be stored in that field.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!