-- 删除序列
drop sequence IF EXISTS test_xh_seq;
-- 从1开始,递增幅度1,最大值无上限
create sequence test_xh_seq increment by 1 minvalue 1 no maxvalue start with 1;
-- 指定序列(给表的主键指定创建好的序列)
alter table test alter column xh set default nextval('test_xh_seq');
-- 设置序列自增长从当前最大值开始
SELECT setval('test_xh_seq', (SELECT MAX(xh) FROM test));