From: | Guillaume Perréal <perreal(at)lyon(dot)cemagref(dot)fr> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | pg_dumpall and check constraints |
Date: | 2000-06-30 07:59:41 |
Message-ID: | 395C536D.A3161C5F@lyon.cemagref.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello.
Here is an extract from my database definition:
CREATE TABLE information (
fieldName text NOT NULL CHECK (fieldName <> ''),
code char NOT NULL CHECK (code <> ''),
label text,
PRIMARY KEY (fieldName, code)
);
-- Filling the table "information"
COPY information FROM stdin;
station.type H hydrological
parameter.type Q discharge
...
\.
-- Function that checks a field value is in the table "information".
CREATE FUNCTION checkInfo(text, char) RETURNS bool AS
'SELECT $2::char IN (SELECT code FROM information WHERE fieldName =
$1::text)'
LANGUAGE 'sql';
-- A table using checkInfo
CREATE TABLE station (
code text NOT NULL,
type char NOT NULL,
name text,
longitude text,
latitude text,
altitude float,
PRIMARY KEY (code),
CONSTRAINT stationCodeNotEmpty
CHECK (code <> ''),
CONSTRAINT existingStationType
CHECK (verifierInfo('station.type', type))
);
As you can guess, the definition order is an important point.
But when I use pg_dumpall, it produces a script that don't respect the order. So
I can't use this script to restore the database.
And the question is: Is there a better way to do what I want (checking field
values from different tables against data in one table) that allow pg_dumpall to
works ?
Thanks.
Guillaume Perréal - Stagiaire MIAG
Cemagref (URH), Lyon, France
Tél: (+33) 4.72.20.87.64
From | Date | Subject | |
---|---|---|---|
Next Message | Karel Zak | 2000-06-30 08:02:31 | Re: Timezone template for to_char(timestamp, '...')? |
Previous Message | Lincoln Yeoh | 2000-06-30 06:52:13 | Re: Leaving transactions open for long periods. Was: NOTICE messages during table drop |