Search Postgresql Archives

Re: set the default schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux