Knowledge Base

February 20, 2008

Take the dump of Postgresql database from Linux console

Filed under: Technical — Tags: , , , , — rkutti @ 12:28 pm

*To dump data or structure in the database from a dump file

$psql -u DBUserName datbaseName < databaseName_dump.sql

*To take the dump from the database

$pg_dump -u databaseName > filename.sql // data + structure
It will ask the username and password of database

$pg_dump -u databaseName -a > filename.sql // only data

$pg_dump -u databaseName -s > filename.sql // only structure

$pg_dump –username=sql-ledger -W databaseName > filename.sql
It will ask the password of database

1 Comment »

  1. The exact command should be:
    $pg_dump –-username=sql-ledger -W databaseName > filename.sql

    or
    $pg_dump –U -W databaseName > filename.sql

    Comment by Sanjay — February 22, 2008 @ 8:23 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.