> SELECT MAX(id) FROM entities;
>
> SELECT nextval('entities_id_seq');
>
> This should be higher than the last result.
>
> If it's not higher... run this to try and fix it. (run a quick
> pg_dump first...)
>
> SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);
Let me up this thread as it just saved my a$$!
Is this considered a bug or a feature? Because people easily get trapped
into it!
--
Posted via http://www.ruby-forum.com/.
I've never needed to do that. I wonder why...would autovacuum help?
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
You might want to look into how that database got backed up. By default (at least every where I've done it) pg_dump will include the statements necessary to "reset" the sequences... that is, all my dumps have lines like this:
SELECT pg_catalog.setval('banners_id_seq', 6, true);
Might be you're missing that or missing the permissions to set that.
-philip
I have the same problem but I don't know how to solve it since I can't
relate the solution here (names of tables, etc.) to the data given by
the OP. How do you know you need to SELECT MAX(id) FROM entities, or
SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);
with the information given by the OP? I can't see the relation and
therefore I have no clue how I can solve my problem.
> This should be higher than the last result.
> SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);
>
...
Thank you so much fro this post!