Home > life is fun > postgres psql tricks

postgres psql tricks


Set all null fields to NULL:

After this, the query results look like this:

Set the command history file names for each host and database:

After this, the history file naming look like this:

Set the number of commands to store in the command history:

Set timing on and see how long query took:

psql prompt can be customized to your preference:

After this, the PROMPT1 look like this:

And PROMPT2 is empty.
Complete information can be found here, under prompting.

Set client encoding:

Final .psqlrc file look like this:

One additional tip is to add less to PAGER environment variable if you want to use less rather than more. So simply add following row to profile (/etc/profile or ~/.profile):

Advertisements
Categories: life is fun
  1. No comments yet.
  1. No trackbacks yet.

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: