位置:首頁 > 數據庫 > PostgreSQL教學 > PostgreSQL算術運算符實例

PostgreSQL算術運算符實例

下麵是簡單的例子,顯示PostgreSQL算術運算符的用法:

testdb=# select 2+3;
 ?column?
----------
        5
(1 row)


testdb=# select 2*3;
 ?column?
----------
        6
(1 row)


testdb=# select 10/5;
 ?column?
----------
        2
(1 row)


testdb=# select 12%5;
 ?column?
----------
        2
(1 row)


testdb=# select 2^3;
 ?column?
----------
        8
(1 row)


testdb=# select |/ 25.0;
 ?column?
----------
        5
(1 row)


testdb=# select ||/ 27.0;
 ?column?
----------
        3
(1 row)


testdb=# select 5 !;
 ?column?
----------
      120
(1 row)


testdb=# select !!5;
 ?column?
----------
      120
(1 row)