Re: Setting schema from command line in psql

From: psql-novice(at)netzach(dot)co(dot)il
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Setting schema from command line in psql
Date: 2007-04-12 16:41:37
Message-ID: 20070412164137.GA16641@netzach.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> I've never tried that, but have you experimented with setting the schema
> from the .psqlrc file? If you can do that then you might be able to get
> .psqlrc to set the schema to a variable which you have set using the -v
> command-line option.

Ingenious. Works a dream. Here are the details of how I did it just in
case somebody else is interested:

begin ~/.psqlrc --------

SET search_path TO :schema;

end file ------------------

mycomputer:~$ psql -v schema=myschema mydb
Welcome to psql 7.old.reallyold, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

SET
mydb=> \dt
List of relations
Schema | Name | Type | Owner
--------------+------------------------------+-------+--------
myschema | table1 | table | me
myschema | table2 | table | me
myschema | table3 | table | me

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas 2007-04-12 17:56:39 Re: server variables ?
Previous Message Duncan Garland 2007-04-12 16:19:23 Re: Setting schema from command line in psql