Skip to main content

Customizing PostgreSQL

The default prompt on PostgreSQL is very basic. It returns only the current database and a # sign.

Changing the prompt can be done with the SET command. So I could set the default prompt to:

\set PROMPT1 '%n@%m-%/=%# '

which would give me:

timb@pdx01aut031-mail=#

Additional information can be found at: http://www.postgresql.org/docs/8.1/static/app-psql.html#APP-PSQL-PROMPTING

Many people get tired of re-entering these commands every time they start the psql client. Luckily, there is a way to set this and execute other commands automatically when connecting to PostgreSQL. This is the use of the .psqlrc file in Linux. NOTE. This file resides in the current directory. In windows, the files should be called psqlrc.conf and is located in the Application DataPostgresql directory (echo %APPDATA%), so there can only be one for each user.