Bit string data types
- Last Updated: March 15, 2016
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Bit string data types
Bit string data types are used to define bit strings, which are sequences of bits having the value of either 0 or 1.
Syntax
This is the syntax for a bit string data type:
|
Parameters
- BIT
-
Corresponds to a single bit value of 0 or 1.
SQL statements can assign and compare values in
BITcolumns to and from columns of typesCHAR,VARCHAR,BINARY,VARBINARY,TINYINT,SMALLINT,and INTEGER.However, in assignments fromBINARYandVARBINARY, the value of the first four bits must be0001or0000.No arithmetic operations are allowed on
BITcolumns. - BINARY [ ( length ) ]
-
Corresponds to a bit field of the specified length of bytes. The default length is 1 byte. The maximum length is 2000 bytes.
When inserting literals into binary data types,
INSERTstatements must use a special format to store values inBINARYcolumns. They can specify the binary values as a bit string, hexadecimal string, or character string.INSERTstatements must enclose binary values in single‑quote marks, preceded bybfor a bit string andxfor a hexadecimal string.The following table lists the specification formats for binary values.
Table 1. Specification formats for binary values Specification Format Example Bit string b''b'1010110100010000'Hexadecimal string x''x'ad10'Character string ' '' ad10'SQL interprets a character string as the character representation of a hexadecimal string.
If the data inserted into a
BINARYcolumn is less than the length specified, SQL pads it with zeros.BINARYdata can be assigned and compared to and from columns of typeBIT,CHAR, andVARBINARY. Arithmetic operations are not allowed. - VARBINARY ( length )
-
Corresponds to a variable‑length bit field of the specified length in bytes. The default length is 1 byte. The maximum length is 31,995 bytes. The default length is 1. Due to index limitations, only the narrower
VARBINARYcolumns can be indexed. - LVARBINARY/BLOB ( length )
-
Corresponds to an arbitrarily long byte array with the maximum length defined by the amount of available disk storage up to 1,073,741,823. A
BLOBis an object of data typeLVARBINARY.