postgresql 自增列 初始值设置
-- 获取自增列的名称
SELECT pg_get_serial_sequence('<your_table>', 'id')) AS sequence_name;
--获取自增列的下一个值:
SELECT nextval(pg_get_serial_sequence('<your_table>', 'id')) AS new_id;
--设置自增列的下一个值:
select setval(pg_get_serial_sequence('<your_table>', 'id'),1,false);
问题

https://stackoverflow.com/questions/62524324/get-all-sequences-with-current-values
select schemaname as schema,
sequencename as sequence,
last_value
from pg_sequences

--max id :244
select * from report."TimezoneAbbreviation" ta order by "Id" desc limit 10
SELECT setval('report."TimezoneAbbreviation_Id_seq"', 244);



浙公网安备 33010602011771号