Postgresql – How to export a table on postgresql command line

postgresql

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

Best Answer

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