HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMajor

How to set a search_path default on a psql cmd execution?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
psqldefaultexecutionsearch_pathhowcmdset

Problem

I'm looking for an option to create an alias command for a psql console connection which allowed setting the search_path, but I am not finding any option on psql util, nor the option to execute a command without exiting. any idea?

I would like to avoid preconditions as setting environment options and have a oneliner if possible

Solution

I finally found it, its not a psql option, but it fits a oneliner:
PGOPTIONS=--search_path=myschema psql -h myHost -U myUser -dmyDb -p myPort.

If anybody improves it with a working version call for both unix and windows ill approve

Context

StackExchange Database Administrators Q#171855, answer score: 30

Revisions (0)

No revisions yet.