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.

Choosing Column Data Types<br />

237<br />

For integer types, you can also specify whether you want them to be UNSIGNED,as<br />

shown in Listing 9.1.<br />

For all numeric types, you can also specify the ZEROFILL attribute.When values from<br />

a ZEROFILL column are displayed, they are padded with leading zeros. If you specify a<br />

column as ZEROFILL, it will automatically also be UNSIGNED.<br />

The integral types are shown in Table 9.5. Note that the ranges listed in this table<br />

show the signed range on one line <strong>and</strong> the unsigned range on the next.<br />

Table 9.5 Integral Data Types<br />

Type Range Storage Description<br />

(Bytes)<br />

TINYINT[(M)] –127..128 1 Very small integers<br />

or 0..255<br />

BIT<br />

Synonym for TINYINT<br />

BOOL<br />

Synonym for TINYINT<br />

SMALLINT[(M)] –32768..32767 2 Small integers<br />

or 0..65535<br />

MEDIUMINT[(M)] –8388608.. 3 Medium-sized integers<br />

8388607<br />

or 0..16777215<br />

INT[(M)] –2 31 ..2 31 –1 4 Regular integers<br />

or 0..2 32 –1<br />

INTEGER[(M)]<br />

Synonym for INT<br />

BIGINT[(M)] –2 63 ..2 63 –1 8 Big integers<br />

or 0..2 64 –1<br />

The floating-point types are shown in Table 9.6.<br />

Table 9.6 Floating-Point Data Types<br />

Type Range Storage Description<br />

(bytes)<br />

FLOAT(precision) Depends on Varies Can be used to specify<br />

precision<br />

single or double precision<br />

floating-point numbers.<br />

FLOAT[(M,D)] ±1.175494351E-38 4 Single precision floating-<br />

±3.402823466E+38<br />

point number.These<br />

numbers are equivalent to<br />

FLOAT(4) but with a<br />

specified display width<br />

<strong>and</strong> number of decimal<br />

places.

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

Saved successfully!

Ooh no, something went wrong!