11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 28 • MYSQL STORAGE ENGINES AND DATA TYPESTINYTEXTThe TINYTEXT data type is <strong>MySQL</strong>’s smallest nonbinary string representation, supporting a maximumlength of 255 characters.ENUM("member1","member2",…"member65,535")The ENUM data type provides a means for storing a maximum of one member chosen from a predefinedgroup consisting of a maximum of 65,535 distinct members. The choice of members is restricted to thosedeclared in the column definition. If the column declaration includes the NULL attribute, then NULL willbe considered a valid value and will be the default. If NOT NULL is declared, the first member of the list willbe the default.SET("member1", "member2",…"member64")The SET data type provides a means for specifying zero or more values chosen from a predefined groupconsisting of a maximum of 64 members. The choice of values is restricted to those declared in thecolumn definition. The storage requirement is 1, 2, 3, 4, or 8 values, depending on the number ofmembers. You can determine the exact requirement with this formula: (N+7)/8, where N is the set size.Data Type AttributesAlthough this list is not exhaustive, this section introduces the attributes you’ll most commonly use, aswell as those that will be used throughout the remainder of this book.AUTO_INCREMENTThe AUTO_INCREMENT attribute takes away a level of logic that would otherwise be necessary in manydatabase-driven applications: the ability to assign unique integer identifiers to newly inserted rows.Assigning this attribute to a column will result in the assignment of the last insertion ID +1 to each newlyinserted row.<strong>MySQL</strong> requires that the AUTO_INCREMENT attribute be used in conjunction with a column designatedas the primary key. Furthermore, only one AUTO_INCREMENT column per table is allowed. An exampleof an AUTO_INCREMENT column assignment follows:id SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEYBINARYThe BINARY attribute is only used in conjunction with CHAR and VARCHAR values. When columns areassigned this attribute, they will be sorted in case-sensitive fashion (in accordance with their ASCIImachine values). This is in contrast to the case-insensitive sorting when the BINARY attribute is omitted.An example of a BINARY column assignment follows:hostname CHAR(25) BINARY NOT NULL543

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

Saved successfully!

Ooh no, something went wrong!