5.3. The BIT Data Type


5.3. The BIT Data Type

The BIT data type represents bit-field values. BIT column specifications take a width indicating the number of bits per value, from 1 to 64 bits. The following columns store 4 and 20 bits per value, respectively:

 bit_col1 BIT(4) bit_col2 BIT(20) 

For a BIT(n) column, the range of values is 0 to 2 n 1, and the storage requirement is approximately INT((n+7)/8) bytes per value.

BIT columns can be assigned values using numeric expressions. To write literal bit values in binary format, the literal-value notation b'val' can be used, where val indicates a value consisting of the binary digits 0 and 1. For example, b'1111' equals 15 and b'1000000' equals 64.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net