Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
9.6. Bit String Functions and Operators
Prev UpChapter 9. Functions and OperatorsHome Next

9.6. Bit String Functions and Operators

This section describes functions and operators for examining and manipulating bit strings, that is values of the typesbit andbit varying. Aside from the usual comparison operators, the operators shown inTable 9.14 can be used. Bit string operands of&,|, and# must be of equal length. When bit shifting, the original length of the string is preserved, as shown in the examples.

Table 9.14. Bit String Operators

OperatorDescriptionExampleResult
||concatenationB'10001' || B'011'10001011
&bitwise ANDB'10001' & B'01101'00001
|bitwise ORB'10001' | B'01101'11101
#bitwise XORB'10001' # B'01101'11100
~bitwise NOT~ B'10001'01110
<<bitwise shift leftB'10001' << 301000
>>bitwise shift rightB'10001' >> 200100

The followingSQL-standard functions work on bit strings as well as character strings:length,bit_length,octet_length,position,substring,overlay.

The following functions work on bit strings as well as binary strings:get_bit,set_bit. When working with a bit string, these functions number the first (leftmost) bit of the string as bit 0.

In addition, it is possible to cast integral values to and from typebit. Some examples:

44::bit(10)000010110044::bit(3)100cast(-44 as bit(12))111111010100'1110'::bit(4)::integer14

Note that casting to justbit means casting tobit(1), and so will deliver only the least significant bit of the integer.


Prev Up Next
9.5. Binary String Functions and Operators Home 9.7. Pattern Matching
epubpdf
Go to Postgres Pro Standard 12
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp