O'Reilly logo

Mastering phpMyAdmin 3.1 for Effective MySQL Management by Marc Delisle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bit

MySQL 5.0.3 introduced true bit-field values. These take the same amount of space in the database as the number of bits in their definition. Let's say we have three pieces of information about each book, and each piece can only be true (1) or false (0):

  • Book is hard cover
  • Book contains a CD-ROM
  • Book is available only in electronic format

We'll use a single BIT field to store these three pieces of information. Therefore, we add a field having a length of 3 (which means 3 bits) to the book table:

Bit

To construct and subsequently interpret the values we store in this field, we have to think in binary, respecting the position of each bit within the field. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required