Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread D'Arcy J.M. Cain
On Thu, 22 Nov 2007 12:11:20 +0100 "Bart Degryse" <[EMAIL PROTECTED]> wrote: > When you use serial a kind of macro is performed: in fact an integer field is > created, a sequence is created with a name based on the table's name and the > nextval of that sequence is used as the default value for t

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread A. Kretschmer
am Thu, dem 22.11.2007, um 12:01:59 +0100 mailte Daniel bodom_lx Graziotin folgendes: > Hi everybody, > I need to have a primary key which has to be unique on two tables. > E.g.: > > CREATE TABLE first > ( > id serial NOT NULL, > testo text, > ) > > CREATE TABLE second > ( > id serial NOT

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread Bart Degryse
When you use serial a kind of macro is performed: in fact an integer field is created, a sequence is created with a name based on the table's name and the nextval of that sequence is used as the default value for the field. Now you have to do these steps "manually". CREATE SEQUENCE "public"."t

[SQL] How to have a unique primary key on two tables

2007-11-22 Thread Daniel "bodom_lx" Graziotin
Hi everybody, I need to have a primary key which has to be unique on two tables. E.g.: CREATE TABLE first ( id serial NOT NULL, testo text, ) CREATE TABLE second ( id serial NOT NULL, testo text, ) When I insert some text on "first", I would like first.id = second.id + 1, and vice versa.