(psycopg2.IntegrityError) duplic
2018-06-20 本文已影响39人
西北望高楼
插入数据时遇到上述标题错误,发现是nextval error.
# 查看表最大id
SELECT MAX(id) FROM area;
-----------------------------------------------
max
-----
630
(1 row)
------------------------------------------------
# 查看该表nextval
SELECT nextval('area_id_seq');
------------------------------------------------
max
-----
630
(1 row)
------------------------------------------------
# 执行修改序列
SELECT setval('area_id_seq', (SELECT MAX(id) FROM area)+1);
------------------------------------------------
setval
--------
631
(1 row)
------------------------------------------------