postgresql duplicate key violates unique constraint

来源:互联网 发布:mac键盘大小写切换 编辑:程序博客网 时间:2024/06/05 16:35
> Throws an exception due to the following SQL error: duplicate key> violates unique constraint.Your primary key index isn't in sync or something.Can you login to psql and run the following?SELECT MAX(id) FROM entities;What is the result?Then run...SELECT nextval('entities_id_seq');This should be higher than the last result.Is it  the same or lower? If so... did you do some importing orrestoring? (your sequence might be off)If it's not higher... run this to try and fix it. (run a quickpg_dump first...)SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);reload your app...and see if its still happening.Good luck!
0 0
原创粉丝点击