Postgresql 大象数据库long自定义自增
Postgresql
--创建序列
CREATE SEQUENCE user_long_id_seq START 100000; CREATE SEQUENCE departments_long_id_seq START 100000; CREATE SEQUENCE positions_long_id_seq START 100000; CREATE SEQUENCE position_grades_long_id_seq START 100000;
--设置对应列Key值 ALTER TABLE users ALTER "id" SET DEFAULT nextval('user_long_id_seq'); ALTER TABLE departments ALTER "id" SET DEFAULT nextval('departments_long_id_seq'); ALTER TABLE positions ALTER "id" SET DEFAULT nextval('positions_long_id_seq'); ALTER TABLE position_grades ALTER "id" SET DEFAULT nextval('position_grades_long_id_seq');
--更新序列
ALTER SEQUENCE user_long_id_seq RESTART WITH 10000
--删除序列
DROP SEQUENCE user_long_id_seq
--查询序列 select * from "user_long_id_seq"