Postgresql-bitwise-operators

提供:Dev Guides
移動先:案内検索

PostgreSQL-ビット演算子

以下に、PostgreSQLのビット単位演算子の使用法を示す簡単な例を示します。

変数Aが60を保持し、変数Bが13を保持すると仮定します-

testdb=# select 60 | 13;
 ?column?
----------
       61
(1 row)


testdb=# select 60 & 13;
 ?column?
----------
       12
(1 row)


testdb=#  select  (~60);
 ?column?
----------
      -61
(1 row)


testdb=# select  (60 << 2);
 ?column?
----------
      240
(1 row)


testdb=# select  (60 >> 2);
 ?column?
----------
       15
(1 row)


testdb=#  select 60 # 13;
 ?column?
----------
       49
(1 row)