echo "SELECT firstname,lastname FROM user WHERE lastname='Newland'" | psql -Uphp -h dbserver userdb > /tmp/query_results.txt
Published January 28th, 2013
How do you dump the results of a SELECT query to a file?
Similar Articles
PostgreSQL 9 pgcrypto Debian
Postgresql increase SHMMAX with sysctl
Postgresql add cascade to existing foreign key constraint
PostgreSQL /var/lib/postgresql/8.4/main/pg_xlog filling up with WAL files
PostgreSQL drop unique constraint
PostgreSQL DROP NULL constraint on COLUMN
SQL get MAX value or NULL (LEFT JOIN example)
Ubuntu sudo postgres createdb
Select unique values in postgres
Load specific columns from CSV file into PostgreSQL
Postgres copy table structure inside database without data
PostgreSQL config, data, log files on Debian
PostgreSQL Debian make a baseline backup for PITR
FATAL: sorry, too many clients already (PostgreSQL)
Run PostgreSQL queries from the command line and export data
PostgreSQL convert BIGINT to date
Get SEDOL from ISIN using SQL (Postgres)
Find biggest tables in postgres
Postgres list databases
Install pgcrypto for Postgres encryption in Debian Lenny
Postgres invalid byte sequence for encoding UTF8
Create and export PGP keys for Postgresql
Postgres list user-defined stored procedures
Postgres dump database schema with or without data
Postgres server to server database copy performance boost
Postgresql increase SHMMAX with sysctl
Postgresql add cascade to existing foreign key constraint
PostgreSQL /var/lib/postgresql/8.4/main/pg_xlog filling up with WAL files
PostgreSQL drop unique constraint
PostgreSQL DROP NULL constraint on COLUMN
SQL get MAX value or NULL (LEFT JOIN example)
Ubuntu sudo postgres createdb
Select unique values in postgres
Load specific columns from CSV file into PostgreSQL
Postgres copy table structure inside database without data
PostgreSQL config, data, log files on Debian
PostgreSQL Debian make a baseline backup for PITR
FATAL: sorry, too many clients already (PostgreSQL)
Run PostgreSQL queries from the command line and export data
PostgreSQL convert BIGINT to date
Get SEDOL from ISIN using SQL (Postgres)
Find biggest tables in postgres
Postgres list databases
Install pgcrypto for Postgres encryption in Debian Lenny
Postgres invalid byte sequence for encoding UTF8
Create and export PGP keys for Postgresql
Postgres list user-defined stored procedures
Postgres dump database schema with or without data
Postgres server to server database copy performance boost