Re: set the default schema - Mailing list pgsql-general

From Scott Marlowe
Subject Re: set the default schema
Date
Msg-id 1164145494.6040.512.camel@state.g2switchworks.com
Whole thread Raw
In response to set the default schema  ("Alain Roger" <raf.news@gmail.com>)
List pgsql-general
On Mon, 2006-11-20 at 12:59, Alain Roger wrote:
> Hi,
>
> I do not own my database. in fact, it is stored on my web hoster
> server.

You must be from oracle land.  Welcome to PostgreSQL land.  It's a
little different.   (as visions of alter session set current_schema swim
through my head).  In PostgreSQL, schemas are NOT tied to users.  They
are a free form thing.  Oracle's a little easier, PostgreSQL is a little
more versatile.

You can do it a few ways.

Let's say you create a new schema test:

create schema test;

and you'd like people who haven't set any parameters to "Drop into" it
when they connect:

alter database test set search_path='test';

poof.  joe user will now drop on top of the test schema.  But wait,
there's more!  you can have more than one.  So, you can do this:

alter database test set search_path='test','public';

Add as many other schemas as you'd like.

Then, as an added bonus, you, the user, can override all that:

alter user smarlowe set search_path = 'abc','public';

Now, all the things that smarlowe creates will go into abc, but using a
table name will search first the abc schema for a match, then the public
schema.

Pretty neat stuff.  Read more here:

http://www.postgresql.org/docs/8.1/static/ddl-schemas.html

tres cool.

pgsql-general by date:

Previous
From: Vic Cekvenich
Date:
Subject: advanced index (descending and table-presorted descending)
Next
From: Casey Duncan
Date:
Subject: Re: Transaction id wraparound and autovacuum