BIT and VARBIT stores bit arrays.
With BIT, the length is fixed; with VARBIT, the length can be variable.
Aliases
The nameBIT VARYING is an alias for VARBIT.
Syntax
Bit array constants are expressed as literals. For example,B'100101' denotes an array of 6 bits.
For more information about bit array constants, see the .
For usage, see the Example below.
Size
The number of bits in aBIT value is determined as follows:
The effective size of a
BIT value is larger than its logical number
of bits by a bounded constant factor. Internally, CockroachDB stores
bit arrays in increments of 64 bits plus an extra integer value to
encode the length.
The total size of a BIT value can be arbitrarily large, but it is
recommended to keep values under 1 MB to ensure performance. Above
that threshold, write
amplification and
other considerations may cause significant performance degradation.
Example
BIT, the value must match exactly the specified size:
VARBIT, the value must not be larger than the specified maximum size:
Supported casting and conversion
BIT values can be to any of the following data types:

