Re: Moving to postgresql and some ignorant questions

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Alban Hertroys" <alban(at)magproductions(dot)nl>
Cc: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>, "Gregory Stark" <stark(at)enterprisedb(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Moving to postgresql and some ignorant questions
Date: 2007-08-14 16:33:37
Message-ID: dcc563d10708140933m5f520636h9cbcafd7dc8f8b37@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/14/07, Alban Hertroys <alban(at)magproductions(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message IVAN JOSE RIVERA URIARTE 2007-08-14 16:39:26 Emigrar SqlServer a Posgres
Previous Message Alban Hertroys 2007-08-14 15:55:21 Re: Moving to postgresql and some ignorant questions