Re: Server/Database/Schema Definitions

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Brandon E Hofmann <Brandon_E_Hofmann(at)notes(dot)ntrs(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Server/Database/Schema Definitions
Date: 2006-05-17 23:53:40
Message-ID: 8AFE4B12-86F7-49C0-B68F-2671632D1C17@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On May 16, 2006, at 10:23 AM, Brandon E Hofmann wrote:

> When coding table and function scripts, how do you specify which
> server/database/schema where you want new tables and functions to
> reside?
> Every time I execute my creation scripts, it puts everything in the
> public
> schema under the PostgreSQL server. I'm new to PostgreSQL and haven't
> found any documentation discussing these characteristics.
>
> Do you explicitly define the server.schema.table_name in the create
> table
> statement? Should the tablespace be set to pg_default and the
> owner to
> postgres?

See this page for a discussion of search_path

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

I typically set the search path at the top of the script. But doing
it like this can certainly trip you up in cases where you might make
changes and do not execute the script from top to bottom (e.g.
redefine a single function).

If I have a specific user (or role) for a certain database or
project, I like to associate the search path with the role so I don't
have to remember to do it every time I work on the database. See
ALTER ROLE SET syntax for details on this:

http://www.postgresql.org/docs/8.1/interactive/sql-alterrole.html

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Samer Abukhait 2006-05-18 00:43:35 Re: Add column and specify the column position in a table
Previous Message Jim C. Nasby 2006-05-17 22:47:02 Re: Server/Database/Schema Definitions