Re: Moving to postgresql and some ignorant questions - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Moving to postgresql and some ignorant questions
Date
Msg-id dcc563d10708140933m5f520636h9cbcafd7dc8f8b37@mail.gmail.com
Whole thread Raw
In response to Re: Moving to postgresql and some ignorant questions  (Alban Hertroys <alban@magproductions.nl>)
List pgsql-general
On 8/14/07, Alban Hertroys <alban@magproductions.nl> wrote:
> *And* you can define compound foreign key constraints,
> for example:
>
> CREATE TABLE employee (
>         employee_id serial NOT NULL,
>         company_id integer NOT NULL,
>         name text NOT NULL,
>         CONSTRAINT employee_pk
>                 PRIMARY KEY (employee_id, company_id)
> );
>
> CREATE TABLE division (
>         employee_id integer NOT NULL,
>         company_id integer NOT NULL,
>         name text NOT NULL,
>         CONSTRAINT division_fk
>                 FOREIGN KEY (employee_id, company_id)
>                         REFERENCES employee
>                         ON DELETE SET NULL
>                         ON UPDATE CASCADE
> );

You can also have multiple foreign keys to different tables, and to
non-primary keys, as long as they are pointing to columns with a
unique constraint on them.

> Also a nice trick, when performing DDL statements (CREATE TABLE and
> friends), you can wrap them in a transaction and commit (or rollback) if
> you like the end result (or not). I believe the only exception to that
> rule is CREATE DATABASE.

One of my all time favorite features of pgsql.

create tablespace is also non-transactable.

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: Moving to postgresql and some ignorant questions
Next
From: Andrew Edson
Date:
Subject: Select time jump after adding filter; please help me figure out what I'm doing wrong.