echo "SELECT foo,bar FROM mytable;" | psql mydbname > /tmp/dumpfile
Published July 22nd, 2011
Need to dump some data from your database into a file but want to use SQL to intelligently select what you export? Here is how to run SQL from the command line using the psql tool
Similar Articles
PostgreSQL 9 pgcrypto Debian
Postgresql increase SHMMAX with sysctl
Postgresql add cascade to existing foreign key constraint
PostgreSQL output query result to file
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)
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 output query result to file
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)
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