HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to export a table on postgresql command line

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqllineexporthowcommandtable

Problem

Anyone can do tell me how to do that?

(I know maybe is a dumb question but I'm trying to learn how to use command line of postgresql)

~$ psql mybase
psql (9.1.3)
Type "help" for help.


and then

mybase=# \dt

            List of relations
 Schema |        Name         | Type  |  Owner   
--------+---------------------+-------+----------
 public | xxxxxx              | table | postgres
 public | xxxxxxx             | table | postgres
 public | xxxxxxxxxxx         | table | postgres
 public | xxxxxxxx            | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxxxxxx        | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxxxx          | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxx            | table | postgres


only want one table to then do a restore =D thanks

Solution

If you want to create text files containing the data, use the COPY command (or the psql command \copy which creates the output files on the client, rather than on the server as the COPY command does).

If you want to create SQL statements use pg_dump

Context

StackExchange Database Administrators Q#17006, answer score: 8

Revisions (0)

No revisions yet.