修改sequence
alter sequence sequence名称 restart with 数字 (字段为long类型主键)
eg.alter sequence pro_exam_sequence restart with 10000001
timestamp 类型计算差值
date_part(‘day’, ‘2019-11-18 12:05’::timestamp - ‘2019-10-18 12:05’::timestamp)
多表更新
update tablename1 aa
set code= bb.code
from (select id,code from tablename2) bb
where aa.id = bb.id
添加字段
ALTER TABLE 表名 ADD COLUMN 字段名 VARCHAR ( 150 );
字段添加注释
comment on column 表名.字段名 is ‘注释’;
表添加注释
comment on table 表名 is ‘表名’;
null时设置其它值
coalesce(字段名, ‘其他值’)
eg.select coalesce(字段名, ‘其他值’) from A