Re: set the default schema

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Alain Roger <raf(dot)news(at)gmail(dot)com>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: set the default schema
Date: 2006-11-21 21:44:54
Message-ID: 1164145494.6040.512.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Casey Duncan 2006-11-21 21:47:51 Re: Transaction id wraparound and autovacuum
Previous Message Magnus Hagander 2006-11-21 21:34:28 Re: list archives