From: | "Alexey V(dot) Meledin" <avm(at)webclub(dot)ru> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Two serial fields, PK identity |
Date: | 1999-12-04 19:23:24 |
Message-ID: | 7932.991204@webclub.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi!
1.
apache=> create table tmp2 (a serial, b serial, name text);
apache=> \ds
Database = apache
+------------------+----------------------------------+----------+
| Owner | Relation | Type |
+------------------+----------------------------------+----------+
| apache | tmp2_b_seq | sequence |
+------------------+----------------------------------+----------+
Where is tmp2_a_seq?
Why there can't be two serial fields at all and parser doesn't say me
about?
2. SERIAL type as PRIMARY KEY
For example:
apache=> create table tmp4 (a serial);
NOTICE: CREATE TABLE will create implicit sequence 'tmp4_a_seq' for SERIAL column 'tmp4.a'
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'tmp4_a_key' for table 'tmp4'
CREATE
apache=> create table tmp5 (a serial primary key);
NOTICE: CREATE TABLE will create implicit sequence 'tmp5_a_seq' for SERIAL column 'tmp5.a'
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'tmp5_pkey' for table 'tmp5'
CREATE
So, I thing, if I use SERIAL I can omit PRIMARY KEY constraint, but
receive PK via SERIAL type.
Then I must define trigger or rule on UPDATE to keep PK IDENTITY.
Is it so?
Regards, Alexey V. Meledin
InterForge Developers Group, Saint-Petersburg
look_to: <www.etcompany.ru><www.businessweb.ru>
<www.inplan.spb.ru><www.pia.ru>>>>>>>>>>>>>>>>>
mail_to: <avm(at)webclub(dot)ru><nick_as: <cureman>>>>
From | Date | Subject | |
---|---|---|---|
Next Message | kaiq | 1999-12-04 19:45:17 | Re: [SQL] arrays |
Previous Message | Tom Lane | 1999-12-04 17:41:32 | Re: [SQL] arrays |