PostgreSQL二三函数
一、系统函数
--查询表是否存在 select count(1) from pg_class where relname = 'net_stream_app_bit_20190814'
二、日期函数
--当前时间 select CURRENT_TIMESTAMP,now(),CURRENT_DATE,current_time --计算时间差 select age( timestamp '2019-08-20 17:00:00',timestamp '2019-07-20 16:30:10') --提取时间的指定域 select extract(HOUR from now()) select date_part('Hour', now()) select date_trunc('quarter', now()) --时间减1秒 select '2019-08-20 17:00:00'::timestamp - '1 second'::interval --判断两个时间域是否相交 select (date '2017-01-01',date '2017-06-01') overlaps (date '2017-05-01',date '2017-10-01');
三、差异性
1、单双引号与大小写问题
select DISTINCT host,src_port from public.net_stream_app_bit_1hour_20190820 where ("src_address", src_port) in (('12.2.2.1', 79),('12.2.2.2', 79)) --对象名(表、索引、字段等)可区分大小写,create table test 默认创建test表,若create table "TEST",则创建TEST表,且使用时必须加双引号,select 1 from "TEST".双引号表示对象名,单引号表示值
仅作为笔记使用,记录信息过于简洁。