From: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> |
---|---|
To: | Rod Taylor <rbt(at)zort(dot)on(dot)ca>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Table/Column Constraints |
Date: | 2000-11-21 05:51:24 |
Message-ID: | 3.0.5.32.20001121165124.02736320@mail.rhyme.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At 00:22 21/11/00 -0500, Rod Taylor wrote:
>Christopher Kings-Lynne wrote:
>
>/*******************************
> * TABLE: example
> *
> * Used to accomplish stuff
> */
>CREATE TABLE example
> ( example_id serial
>
> /* Must be a ZIP or Postal Code */
> , region varchar(6) UNIQUE
> NOT NULL
>
> /* Descriptive text */
> , description varchar(60) NOT NULL
> );
From the point of view of efficient dump & load, I think you actually need
to dump:
CREATE TABLE example
( example_id serial
-- Must be a ZIP or Postal Code
, region varchar(6)
-- Descriptive text
, description varchar(60)
);
Followed by:
ALTER TABLE example Alter Column region UNIQUE NOT NULL;
...etc. (Whatever the correct syntax is).
The reason for this is that UNIQUE constraints in particular are probably
very nasty things to check when loading a table. I would expect it to be
more efficient to create tables, load them, and define constraints. Also,
for FK constraints this is essential. Unless of course someone implements a
'SET ALL CONSTRAINTS OFF/ON'.
It is also nice to be able to dump constraints only.
So it's definitely a good idea to separate them, IMO.
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/
From | Date | Subject | |
---|---|---|---|
Next Message | Larry Rosenman | 2000-11-21 06:03:05 | Re: [HACKERS] Re: pgsql/src/backend/access/transam (xlog.c) |
Previous Message | Thomas Lockhart | 2000-11-21 05:42:19 | Re: Table/Column Constraints |