Postgres 修改 sequence

----删除前先解除 id 对该序列的依赖
ALTER TABLE tablename ALTER COLUMN id SET DEFAULT null;
DROP SEQUENCE IF EXISTS sequence_name;
---- id_max 即 id 目前的最大值,可写为1,可通过 “SELECT MAX(id) FROM tablename” 得到
CREATE SEQUENCE sequence_name START WITH id_max;
ALTER TABLE tablename ALTER COLUMN id SET DEFAULT nextval('sequence_name'::regclass)

转载:https://blog.csdn.net/quanqxj/article/details/77505247

 

posted @ 2020-11-10 10:08  Cool·  阅读(1584)  评论(0编辑  收藏  举报