Skip to content

using psql to run sql queries in console

July 9, 2013

use the -c option for entering the query
If you want the output to be printed without it being interactive (or using a buffer?) redirect the out put to /dev/null (i.e. use < /dev/null at the end of the command)


$psql -d 'my_db' -c 'select * from my_table' < /dev/null

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: