Reputation: 369
I dumped a database and try to restore in the same server but in another database with another user and get some error because in the dump there are some alter table to the original user.
I did it with this commands:
Dump:
pg_dump --format=c -W -h remote.server -U originaluser originaldatabase >somefile.sql
Restore:
pg_restore -W -h remote.server -U destuser --dbname=destdatabase somefile.sql
How can i make a dump like mysqldump in mysql? So when i import the dump the index and the tables are owned by the user that is executing the import.
Thank you.
PD: I try with psql too with this line:
psql -h remote.server -W -U destuser destdatabase < somefile.sql
The error i got is that the sequence alredy exists, some table have serial8 so have a function and a sequence. How to export with different names or import in the new database without this error?
Thank you.
Upvotes: 0
Views: 623
Reputation: 369
I found my problem, when you delete the table you did not delete the sequence. You must delete the sequence too.
The error was because the sequence alredy exists and is not stored inside the table. You must delete the table and the sequences so you would look inside the table for all the sequences so you can delete the right ones.
Thank you.
Upvotes: 0