I get the following error while restoring database from dump file on server:
ERROR: relation "table_id_seq" does not exist
LINE 1: SELECT pg_catalog.setval('table_id_seq', 362, true);
Here is my dump command:
pg_dump -U username -h localhost db_name > filename.sql
Here is my restore command on server:
psql -U username -h localhost db_name < filename.sql
Please help, Thanks.
After I got information from @clemens and make some research I found that, in my dump file on section CREATE SEQUENCE table_id_seq
has a statement AS integer
that why when I restored into new database it did not create the nextval()
for the sequence. If I remove the statement AS integer
from the CREATE SEQUENCE
section it works find.
In my dump file:
CREATE SEQUENCE table_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
Remove AS integer
from dump file
CREATE SEQUENCE table_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
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