Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jixiaolong/ab1d3a3403c91b89c9472525e019e489 to your computer and use it in GitHub Desktop.

Select an option

Save jixiaolong/ab1d3a3403c91b89c9472525e019e489 to your computer and use it in GitHub Desktop.
django 中使用postgres报duplicate key value violates unique constraint error
question:
-----------------
IntegrityError: duplicate key value violates unique constraint "eshop_screeninformation_pkey"
DETAIL: Key (id)=(1) already exists.
------------------
answer:
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment