Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources]

Kevin Yank

نسخه متنی -صفحه : 190/ 127
نمايش فراداده

Numerical Types

TINYINT[(M)]

Description: A tiny integer value.

Attributes allowed: UNSIGNED, ZEROFILL

Range: -128 to 127 (0 to 255 if UNSIGNED)

Storage space: 1 byte (8 bits)

SMALLINT[(M)]

Description: A small integer value.

Attributes allowed: UNSIGNED, ZEROFILL

Range: -32768 to 32767 (0 to 65535 if UNSIGNED)

Storage space: 2 bytes (16 bits)

MEDIUMINT[(M)]

Description: A medium integer value.

Attributes allowed: UNSIGNED, ZEROFILL

Range: -8588608 to 8388607 (0 to 16777215 if UNSIGNED)

Storage space: 3 bytes (24 bits)

INT[(M)]

Description: A regular integer value.

Attributes allowed: UNSIGNED, ZEROFILL

Range: -2147483648 to 2147483647 (0 to 4294967295 if UNSIGNED)

Storage space: 4 bytes (32 bits)

Alternative syntax: INTEGER[(M)]

BIGINT[(M)]

Description: A large integer value.

Attributes allowed: UNSIGNED, ZEROFILL

Range: -9223372036854775808 to 9223372036854775807 (0 to 18446744073709551615 if UNSIGNED)

Storage space: 8 bytes (64 bits)

Notes: MySQL performs all integer arithmetic functions in signed BIGINT format; thus, BIGINT UNSIGNED values over 9223372036854775807 (63 bits) will only work properly with bit functions (e.g. bit-wise AND, OR, and NOT). Attempting integer arithmetic with larger values may produce inaccurate results due to rounding errors.

FLOAT[(M,D)],FLOAT(precision)

Description: A floating point number.

Attributes allowed: ZEROFILL

Range: 0 and 1.175494351E-38 to 3.402823466E+38

Storage space: 4 bytes (32 bits)

Notes: precision (in bits), if specified, must be less than or equal to 24, or else a DOUBLE column will be created instead (see below).

DOUBLE[(M,D)],DOUBLE(precision)

Description: A high-precision floating point number.

Attributes allowed: ZEROFILL

Range: 0 and 2.2250738585072014-308 to 1.7976931348623157E+308

Storage space: 8 bytes (64 bits)

Notes: precision (in bits), if specified, must be greater than or equal to 25, or else a FLOAT column will be created instead (see above). precision may not be greater than 53.

Alternative syntax: DOUBLE PRECISION[(M,D)] or REAL([M,D])

DECIMAL[(M[,D])]

Description: A floating point number stored as a character string.

Attributes allowed: ZEROFILL

Range: As for DOUBLE, but constrained by M and D (see Notes).

Storage space: M+2 bytes (8M+16 bits) (see Notes prior to MySQL 3.23)

Notes: If D is not specified, it defaults to 0 and numbers in this column will have no decimal point or fractional part. If M is not specified, it defaults to 10. In versions of MySQL prior to 3.23, M had to include space for the negative sign and the decimal point, so the storage space required was M bytes (8M bits). The newer format in MySQL 3.23 or later is ANSI SQL compliant.

Alternative syntax: NUMERIC([M[,D]])