当postgresql表中主键自增出现问题…

前端之家收集整理的这篇文章主要介绍了当postgresql表中主键自增出现问题…前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

SELECT MAX(id) FROM your_table;

// Then run...
// This should be higher than the last result.
SELECT nextval('your_table_id_seq');

// If it's not higher... run this to try and fix it. (run a quick pg_dump first...)
SELECT setval('
your_table_id_seq', (SELECT MAX(id) FROM your_table)+1);
原文链接:https://www.f2er.com/postgresql/195893.html

猜你在找的Postgre SQL相关文章