I believe you can do something like the following to output a csv file (<database> is the name of your database):
Code:
psql -A -q -t -F, -d <database> -o database.csv -c 'select * from table'
An even better way would be to use 'pg_dump', but it will output sql statements.
Have a look at the man page for pg_dump and find the '-T' option.
Here is an example: (<tablename> is the name of the table ... <database> is the name of the database):
Code:
pg_dump -T '<tablename>' <database> > mydb_table.sql