23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Bit string data types<br />

<strong>Data</strong> types<br />

Bit string data types are used to define bit strings, which are sequences of bits having the value<br />

of either 0 or 1. This is the syntax for a bit string data type:<br />

Syntax<br />

BIT | BINARY | VARBINARY | LVARBINARY [ ( length ) ]<br />

BIT<br />

Corresponds to a single bit value of 0 or 1.<br />

<strong>SQL</strong> statements can assign and compare values in BIT columns to and from columns of<br />

types CHAR, VARCHAR, BINARY, VARBINARY, TINYINT, SMALLINT, and INTEGER. However,<br />

in assignments from BINARY and VARBINARY, the value of the first four bits must be 0001<br />

or 0000.<br />

No arithmetic operations are allowed on BIT columns.<br />

BINARY [ ( length ) ]<br />

Corresponds to a bit field of the specified length of bytes. The default length is 1 byte. The<br />

maximum length is 2000 bytes.<br />

When inserting literals into binary data types, INSERT statements must use a special format<br />

to store values in BINARY columns. They can specify the binary values as a bit string,<br />

hexadecimal string, or character string. INSERT statements must enclose binary values in<br />

single-quote marks, preceded by b for a bit string and x for a hexadecimal string. Table 48<br />

lists the specification formats for binary values.<br />

Table 48: Specification formats for binary values<br />

Specification Format Example<br />

Bit string b ' ' b '1010110100010000'<br />

Hexadecimal string x ' ' x 'ad10'<br />

Character string ' ' 'ad10'<br />

<strong>SQL</strong> interprets a character string as the character representation of a hexadecimal string.<br />

If the data inserted into a BINARY column is less than the length specified, <strong>SQL</strong> pads it with<br />

zeros.<br />

BINARY data can be assigned and compared to and from columns of type BIT, CHAR, and<br />

VARBINARY. Arithmetic operations are not allowed.<br />

VARBINARY ( length )<br />

Corresponds to a variable-length bit field of the specified length in bytes. The default<br />

length is 1 byte. The maximum length is 31,995 bytes. The default length is 1. Due to<br />

index limitations, only the narrower VARBINARY columns can be indexed.<br />

199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!