PostgreSql 序列的处理


-- 查看最大值
select max(id) from t_sys_personrole;

-- 删除序列级联
-- DROP SEQUENCE test_c_id_seq CASCADE;

-- 创建序列
CREATE SEQUENCE seq_t_sys_personrole
START WITH 22
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

-- 更改表的字段与序列对应
alter table t_sys_personrole alter column id set default nextval('seq_t_sys_personrole');

原文地址:https://www.cnblogs.com/littlehb/p/3037853.html