From: | Christian Schröder <cs(at)deriva(dot)de> |
---|---|
To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
Cc: | Simon Connah <simon(dot)n(dot)connah(at)btopenworld(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: No serial type |
Date: | 2008-11-18 23:16:19 |
Message-ID: | 49234CC3.4030306@deriva.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott Marlowe wrote:
> Serial is a "pseudotype". It represents creating an int or bigint and
> a sequence then assigning a default value for the column and setting
> dependency in the db so the sequence will be dropped when the table
> gets dropped. If you don't want to recreate the table, you can do
> this:
>
> create table a (i int primary key, info text);
> create sequence a_i_seq;
> alter table a alter column i set default nextval('a_i_seq');
>
You could even use "create sequence a_i_seq owned by a.i". This would
cause the sequence to be dropped when the table is dropped which I think
is the default behaviour if you create a column with type serial.
Regards,
Christian
--
Deriva GmbH Tel.: +49 551 489500-42
Financial IT and Consulting Fax: +49 551 489500-91
Hans-Böckler-Straße 2 http://www.deriva.de
D-37079 Göttingen
Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer
From | Date | Subject | |
---|---|---|---|
Next Message | Erik Jones | 2008-11-18 23:38:34 | Re: No serial type |
Previous Message | Tom Lane | 2008-11-18 22:15:44 | Re: apparent deadlock |