2

I have two servers running same PostgreSQL databases where one is production and one is development snapshot. It would be very handy for me if I could show the server name in the psql prompt (like this):

database_name@server_name > 

Is there any way to achieve this?

Edit

edem's answer guided me into the right direction - setting the PROMPT1 variable in ~/.psqlrc. The only problem was that I was connecting to the database via Unix domain socket, so it printed local instead of server name.

I've used documentation and this forum post, combined them and got this as a content of .psqlrc file:

 \set PROMPT1 '%/@%`hostname`:%>%R%#%x%x%x '

and now my prompt looks like:

database_name@my_database_server.com:5455=# 

1 Answer 1

3

In your $HOME directory make the file .psqlrc with this: \set PROMPT1 '%/@%M %# '

Then go into to psql and you will see something like this: username@[local] >

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .