Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database restore errors

Status
Not open for further replies.

roycrom

Programmer
Aug 2, 2002
184
GB
I have upgraded from postgreSQL 7.0.2 to 7.2.1. I pg_dump my database and then I use psql to restore on new server.

Before my restore I used "createdb dbname" - and this generated the name as a number instead of putting it in as dbname. Then when I used "psql -d dbname -f dbname.dump" - the database name that was on the old server remains as the number generated by createdb such as 16555.

How do I restore so name is retained?
 
"createdb dbname" never generates the name as a number. When it responds with a number such as 16555 that is the Object Identifier, or oid. If you list the databases, you should still see your newly created dbname.

One thing to remember though: pg_dump usually includes the original database name creation statement inside it, as well as the table creation statements.

Open up your dump file in an editor, and you should see near the top that it has the command to re-create the original database name, and then re-connect to that database before continuing with the restore. So, if you run psql -d newdbname -f dbname.dump, it will still create 'olddbname', and reconnect to 'olddbname' before continuing with the restore. Just edit that section or delete that section and then run your command. -------------------------------------------

"Now, this might cause some discomfort..."
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top