Re: Table/Column Constraints

Поиск
Список
Период
Сортировка
От Philip Warner
Тема Re: Table/Column Constraints
Дата
Msg-id 3.0.5.32.20001121165124.02736320@mail.rhyme.com.au
обсуждение исходный текст
Ответ на Re: Table/Column Constraints  (Rod Taylor <rbt@zort.on.ca>)
Ответы RE: Table/Column Constraints  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Список 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   |/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: djm@web.us.uu.net (David J. MacKenzie)
Дата:
Сообщение: Re: Re: [PATCHES] PostgreSQL virtual hosting support
Следующее
От: "Vadim Mikheev"
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql/src/backend/access/transam (xlog.c)