0

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.

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.