If you attempt to set a sequence number like this:
SELECT setval('table_ID_seq', (SELECT max("ID") + 1 FROM table));
You might encounter the following error:
ERROR: relation "table_ID_seq" does not exist
LINE 1: SELECT setval('table_ID_seq', (SELECT max("ID") + 1 FROM t...
^
********** Error **********
ERROR: relation "table_id_seq" does not exist
SQL Status:42P01
The problem is that PostgreSQL will normalize identifier names unless they are put in double quotes.
However, this will not work:
SELECT setval("table_ID_seq", (SELECT max("ID") + 1 FROM table));
Instead, you will have to put single-quotes around the double-quoted text:
SELECT setval('"table_ID_seq"', (SELECT max("ID") + 1 FROM table));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With