In MySQL, what is bitfield notation and how to use it to write bitfield values?

WBOY
Release: 2023-08-24 09:45:06
forward
540 people have browsed it

In MySQL, what is bitfield notation and how to use it to write bitfield values?

Bit-field notation is the notation with the help of which we can write bit-field values. The syntax of Bit-field notation is as follows −

Syntax

b’value’ OR 0bvalue
Copy after login

Here, the value is a binary value written by using zeros and ones.

The mainly Bit-filed notation is convenient for specifying values to be assigned to BIT columns of MySQL table. Following example will demonstrate it −

mysql> Create table bit_testing (bittest BIT(8)); Query OK, 0 rows affected (1.09 sec) mysql> INSERT INTO bit_testing SET bittest = b'10101010'; Query OK, 1 row affected (0.07 sec) mysql> INSERT INTO bit_testing SET bittest = b'0101'; Query OK, 1 row affected (0.13 sec) mysql> INSERT INTO bit_testing SET bittest = 0b0101; Query OK, 1 row affected (0.10 sec)
Copy after login

The above is the detailed content of In MySQL, what is bitfield notation and how to use it to write bitfield values?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!