February 2018
Intermediate to advanced
510 pages
16h 10m
English
Have you ever come across a requirement to store binary representations of numbers? Can you think of such use cases? One such use case is to store weekly working days information for a year. We will touch base on this example later in the section.
The BIT data type is used to store binary bits or groups of bit values. It is also one of the options to store Boolean, yes/no or 0/1 values.
The BIT type column can be defined as:
column_name BITorcolumn_name BIT(m)where m = number of bits to be stored
For a BIT data type, m can vary from 1 to 64. Supplying m is optional. The default value for m is 1.
The following is an example of how a BIT column can be defined:
CREATE TABLE working_days (year INT,week INT,days BIT(7),PRIMARY KEY ...
Read now
Unlock full access