PostgreSQL踩坑记录 Key (id)=(1) already exists

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a624806998/article/details/79026592

PostgreSQL踩坑记录

在进行数据库记录的迁移和复制数据后容易出现错误

DETAIL:  Key (id)=(1) already exists.

解决方案:

select setval('tablename_id_seq', max(id)) from tablename;

在此记录一下,因为感觉需要用到的次数有点频繁

猜你喜欢

转载自blog.csdn.net/a624806998/article/details/79026592