操作符
求差集操作符:MINUS
atlasdb=# select 1 minus select 1;
不等于操作符:^=
atlasdb=# select 1^=1; -[ RECORD 1 ] ?column? | f
时间 + 整数操作符:date + int
atlasdb=# select sysdate,sysdate+1; -[ RECORD 1 ]----------------- sysdate | 2020-03-09 08:33:18 ?column? | 2020-03-10 08:33:18
时间 - 整数操作符:date – int
atlasdb=# -[ RECORD 1 ]----------------- sysdate | 2020-03-09 08:33:46 ?column? | 2020-02-27 08:33:46
时间 + 字符操作符:date + text
atlasdb=# select sysdate,sysdate+11::text; sysdate | ?column? ---------------------+--------------------- 2020-05-18 09:34:06 | 2020-05-29 09:34:06 (1 row)
时间 - 字符操作符:date - text
atlasdb=# select sysdate,sysdate-11::text; sysdate | ?column? ---------------------+--------------------- 2020-05-18 09:33:54 | 2020-05-07 09:33:54 (1 row) atlasdb=# select sysdate-'2020-05-18 09:52:00',sysdate; ?column? | sysdate ----------+--------------------- 0.001482 | 2020-05-18 09:54:08 (1 row)
时间与字符的比较
atlasdb=# select sysdate>'2020-05-17'::text,sysdate; ?column? | sysdate ----------+--------------------- t | 2020-05-18 09:36:28 (1 row) atlasdb=# select sysdate>='2020-05-17'::text,sysdate; ?column? | sysdate ----------+--------------------- t | 2020-05-18 09:36:34 (1 row) atlasdb=# select sysdate<'2020-05-17'::text,sysdate; ?column? | sysdate ----------+--------------------- f | 2020-05-18 09:36:37 (1 row) atlasdb=# select sysdate<='2020-05-17'::text,sysdate; ?column? | sysdate ----------+--------------------- f | 2020-05-18 09:36:40 (1 row) atlasdb=# select sysdate='2020-05-17'::text,sysdate; ?column? | sysdate ----------+--------------------- f | 2020-05-18 09:36:43 (1 row)
时间 - 时间操作符:date – date
atlasdb=# select sysdate-(sysdate-11); -[ RECORD 1 ] ?column? | 11
数值类型+/- 字符 操作符
atlasdb=# select 1::bigint+'1'::text; ?column? ---------- 2 (1 row) atlasdb=# select 1::int+'1'::text; ?column? ---------- 2 (1 row) atlasdb=# select 1::smallint+'1'::text; ?column? ---------- 2 (1 row) atlasdb=# select 1::bigint-'1'::text; ?column? ---------- 0 (1 row) atlasdb=# select 1::int-'1'::text; ?column? ---------- 0 (1 row) atlasdb=# select 1::smallint-'1'::text; ?column? ---------- 0 (1 row) atlasdb=# select 1.1::float+'1'::text; ?column? ---------- 2.1 (1 row) atlasdb=# select 1.1::double precision+'1'::text; ?column? ---------- 2.1 (1 row) atlasdb=# select 1.1::number+'1'::text; ?column? ---------- 2.1 (1 row) atlasdb=# select 1.1::float-'1'::text; ?column? ---------- 0.1 (1 row) atlasdb=# select 1.1::double precision-'1'::text; ?column? ---------- 0.1 (1 row) atlasdb=# select 1.1::number-'1'::text; ?column? ---------- 0.1 (1 row)
数值类型 *、/ 字符 操作符
atlasdb=# select 3::smallint/'2'::text; ?column? ---------- 1.5 (1 row) atlasdb=# select 3::bigint/'2'::text; ?column? -------------------- 1.5000000000000000 (1 row) atlasdb=# select 3::int/'2'::text; ?column? ---------- 1.5 (1 row) atlasdb=# select 3::int*'2'::text; ?column? ---------- 6 (1 row) atlasdb=# select 3::bigint*'2'::text; ?column? ---------- 6 (1 row) atlasdb=# select 3::smallint*'2'::text; ?column? ---------- 6 (1 row) atlasdb=# select 3.8::float/'2'::text; ?column? ---------- 1.9 (1 row) atlasdb=# select 3.8::double precision /'2'::text; ?column? ---------- 1.9 (1 row) atlasdb=# select 3.8::number /'2'::text; ?column? -------------------- 1.9000000000000000 (1 row)
数值型与字符型的比较
atlasdb=# select 1='1'::text; ?column? ---------- t (1 row) atlasdb=# select 10='1'::text; ?column? ---------- f (1 row) atlasdb=# select 10>'1'::text; ?column? ---------- t (1 row) atlasdb=# select 10>='1'::text; ?column? ---------- t (1 row) atlasdb=# select 10<='1'::text; ?column? ---------- f (1 row) atlasdb=# select 10<'1'::text; ?column? ---------- f (1 row) atlasdb=# select 10<>'1'::text; ?column? ---------- t (1 row) atlasdb=# select 10::float <>'1'::text; ?column? ---------- t (1 row) atlasdb=# select 10::float >'1'::text; ?column? ---------- t (1 row) atlasdb=# select 10::float >='1'::text; ?column? ---------- t (1 row) atlasdb=# select 10::float <='1'::text; ?column? ---------- f (1 row) atlasdb=# select 10::float <'1'::text; ?column? ---------- f (1 row)
连接操作符||
atlasdb=# select 'atlasdb'||2; ?column? ---------- atlasdb2 (1 row)