- + 加法运算
示例:
gbase=# SELECT 2+3 AS RESULT;
result
--------
5
(1 row)
- - 减法运算
示例:
gbase=# SELECT 2-3 AS RESULT;
result
--------
-1
(1 row)
- * 乘法运算
示例:
gbase=# SELECT 2*3 AS RESULT;
result
--------
6
(1 row)
- / 除法运算
示例:
gbase=# SELECT 4/2 AS RESULT;
result
--------
2
(1 row)
gbase=# SELECT 4/3 AS RESULT;
result
------------------
1.33333333333333
(1 row)
- +/- 正/负
示例:
gbase=# SELECT -2 AS RESULT;
result
--------
-2
(1 row)
- % 模(求余)运算
示例:
gbase=# SELECT 5%4 AS RESULT;
result
--------
1
(1 row)
- @ 取绝对值
示例:
gbase=# SELECT @ -5.0 AS RESULT;
result
--------
5.0
(1 row)
- ^ 幂运算
示例:
gbase=# SELECT 2.0^3.0 AS RESULT;
result
--------------------
8.0000000000000000
(1 row)
- |/ 求平方根运算
示例:
gbase=# SELECT |/ 25.0 AS RESULT;
result
--------
5
(1 row)
- ||/ 求立方根运算
示例:
gbase=# SELECT ||/ 27.0 AS RESULT;
result
--------
3
(1 row)
- ! 阶乘运算
示例:
gbase=# SELECT 5! AS RESULT;
result
--------
120
(1 row)
- !! 阶乘运算(带前缀操作符)
示例:
gbase=# SELECT !!5 AS RESULT;
result
--------
120
(1 row)
- & 二进制与运算 AND
示例:
gbase=# SELECT 91&15 AS RESULT;
result
--------
11
(1 row)
- | 二进制或运算OR
示例:
gbase=# SELECT 32|3 AS RESULT;
result
--------
35
(1 row)
- # 二进制异或运算XOR
示例:
gbase=# SELECT 17#5 AS RESULT;
result
--------
20
(1 row)
- ~ 二进制非运算NOT
示例:
gbase=# SELECT ~1 AS RESULT;
result
--------
-2
(1 row)
- << 二进制左移
示例:
gbase=# SELECT 1<<4 AS RESULT;
result
--------
16
(1 row)
- >> 二进制右移
示例:
gbase=# SELECT 8>>2 AS RESULT;
result
--------
2
(1 row)