13th August 2020: PostgreSQL 12.4, 11.9, 10.14, 9.6.19, 9.5.23, and 13 Beta 3 Released!

This documentation is for an unsupported version of PostgreSQL.

You may want to view the same page for the current version, or one of the supported versions listed above instead.

You may want to view the same page for the current version, or one of the supported versions listed above instead.

Bit strings are strings of 1's and 0's. They can be used to
store or visualize bit masks. There are two SQL bit types:
`BIT( x)` and

`BIT` type data must match the length
`x` exactly; it is an error to
attempt to store shorter or longer bit strings. `BIT VARYING` is of variable length up to the maximum
length `x`; longer strings will be
rejected. `BIT` without length is equivalent
to `BIT(1)`, `BIT
VARYING` without length specification means unlimited
length.

Note:Prior to PostgreSQL 7.2,BITtype data was zero-padded on the right. This was changed to comply with the SQL standard. To implement zero-padded bit strings, a combination of the concatenation operator and the`substring`

function can be used.

Refer to Section 1.1.2.2 for information about the syntax of bit string constants. Bit-logical operators and string manipulation functions are available; see Chapter 4.