Two serial fields, PK identity

Поиск
Список
Период
Сортировка
От Alexey V. Meledin
Тема Two serial fields, PK identity
Дата
Msg-id 7932.991204@webclub.ru
обсуждение исходный текст
Список 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@webclub.ru><nick_as: <cureman>>>>




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

Предыдущее
От:
Дата:
Сообщение: Re: [SQL] arrays
Следующее
От: "Alexey V. Meledin"
Дата:
Сообщение: Postgres Date/Time Special Constants