Setting schema from command line in psql

From: psql-novice(at)netzach(dot)co(dot)il
To: pgsql-novice(at)postgresql(dot)org
Subject: Setting schema from command line in psql
Date: 2007-04-12 13:57:04
Message-ID: Pine.LNX.4.58.0704121654280.32231@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I keep a large number of separate development projects in a single
database, each in its own schema. Whenever I wish to work on one of them
in psql, after running

psql <dbname>

I then have to type

SET search_path TO <schemaname> [, PUBLIC] ;

I would really like to be able to do this from the command line, so that
I can make a wrapper for it, something like 'openproject <pname>'.

I read through the manual and the closest thing I could find was --set,
but this handles psql environment variables, which do not, as far as I
can see, affect the search_path.

Ideally I would like something like this:

psql --schema <schemaname> <- pg_dump already supports this

Or, perhaps better:

psql --before-starting-execute-this-command "SET search_path....

(or a similar more digestable syntax)

Have I missed something in the docs ?

Thanks,

Daniel

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Aaron Woehler 2007-04-12 14:48:53 Seeking Restoration Advice
Previous Message A. Kretschmer 2007-04-12 09:48:42 Re: placing position numbers on a query output