use a pre-insert triggers - one for each table. include something like
I ended up going this route and it seems to work. Thanks for the help
from all. I figured i'd post the solution to the list so it shows up
when googled. Also, if my solution can be simplfied i'd appreciate
knowing how.
Th
D]
On Behalf Of Peter Eisentraut
Sent: Wednesday, 28 March 2007 19:08
To: pgsql-sql@postgresql.org
Cc: Phillip Smith; 'Jon Horsman'
Subject: Re: [SQL] Foreign Unique Constraint
Am Mittwoch, 28. März 2007 00:17 schrieb Phillip Smith:
> Perhaps this...? It would work, but depending how
Subqueries are not allowed in check constraints.
I hadn't tried this yet but i'm sure i would have figured this out
quickly then =)
Thanks,
Jon
---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings
Am Mittwoch, 28. März 2007 00:17 schrieb Phillip Smith:
> Perhaps this...? It would work, but depending how many rows are in the
> table, it could become incredibly slow.
>
> ALTER TABLE table1 ADD CHECK (extension NOT IN (SELECT extension FROM
> table2));
Subqueries are not allowed in check const
Perhaps this...? It would work, but depending how many rows are in the
table, it could become incredibly slow.
The max rows in either table would be about 1000 or so, which isn't
too many. There also should be a hole lot of inserting going on.
ALTER TABLE table1 ADD CHECK (extension NOT IN (S
));
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jon Horsman
Sent: Tuesday, 27 March 2007 23:22
To: pgsql-sql@postgresql.org
Subject: [SQL] Foreign Unique Constraint
I was wondering if someone could help point me in the right direction
w.r.t. foreign
>
> create table table1 (
> id SERIAL PRIMARY KEY
> extension UNIQUE,
>
> )
>
> create table table2 (
> id SERIAL PRIMARY KEY
> extension UNIQUE,
>
> )
>
> Basically table 1 and table 2 both have the concept of an extension
> that must be unique but the rest of the info in the tables are
> di
Jon Horsman wrote:
> Basically table 1 and table 2 both have the concept of an extension
> that must be unique but the rest of the info in the tables are
> different. I need to ensure that if i add an entry to table 1 with
> extension 1000 that it will fail if there is already an entry in
> table2
> create table table1 (
> id SERIAL PRIMARY KEY
> extension UNIQUE,
I can't find anything about this syntax in the docs...
Oops, i'm missing a comma on that first line, should have been:
create table table1 (
id SERIAL PRIMARY KEY,
extension UNIQUE,
)
I think, you should write a TRIGGER for
am Tue, dem 27.03.2007, um 9:21:44 -0400 mailte Jon Horsman folgendes:
> I was wondering if someone could help point me in the right direction
> w.r.t. foreign unique constraints. I'm working on a legacy database
> and have a new requirement and am not sure how to do it.
>
> I have something li
I was wondering if someone could help point me in the right direction
w.r.t. foreign unique constraints. I'm working on a legacy database
and have a new requirement and am not sure how to do it.
I have something like this
create table table1 (
id SERIAL PRIMARY KEY
extension UNIQUE,
)
create
11 matches
Mail list logo