Pages

Friday, February 4, 2011

How to Import / Export in Postgres Database ?

1. To Export the Schema details(Database) to a SQL File :
Switch to postgres user
su postgres
pg_dump DatabaseName > output.sql

Now the  Schema details will be saved in output.sql file

2.To Import the Schema  from SQL file to Database:
Switch to postgres user
su postgres
pg_dump DatabaseName < Input_Schema.sql

Now the Schema details in the Input_Schema.sql will be imported into postgres
database with the name "DatabaseName"

No comments:

Post a Comment