PostgreSQL – How to Set a search_path Default on psql Command Execution

postgresqlpsql

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

Best Answer

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