Home Tutorial Php Sql MySQL BIT

 
 

Share on Google+Share on Google+
MySQL BIT
Posted on: December 9, 2010 at 12:00 AM
Advertisement
This example illustrates how to create the table with BIT type field.

MySQL BIT

This example illustrates how to create the table with BIT type field.

In this example we create a table with BIT type field and insert some binary value and then select the table as binary, octal and hexadecimal format. The output is showing in the all three format after converting in the associative format.

 

Query

 

CREATE TABLE t (b BIT(8));

 

Query

 

INSERT INTO t SET b = b'11111111';

 

Query

 

INSERT INTO t SET b = b'1010';

 

Query

 

INSERT INTO t SET b = b'0101';

 

Query
 

 

SELECT b+0, BIN(b+0), OCT(b+0), HEX(b+0) FROM t;
Output

 

+------+----------+----------+----------+
| b+0  | BIN(b+0) | OCT(b+0) | HEX(b+0) |
+------+----------+----------+----------+
| 255  | 11111111 | 377      | FF       |
| 10   | 1010     | 12       | A        |
| 5    | 101      | 5        | 5        |
+------+----------+----------+----------+

 

Advertisement

Related Tags for MySQL BIT:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com