Re: ALTER TABLE with TYPE serial does not work - Mailing list pgsql-general

From Scott Marlowe
Subject Re: ALTER TABLE with TYPE serial does not work
Date
Msg-id dcc563d10902010236h1fe8ce9fj4917467d102a5395@mail.gmail.com
Whole thread Raw
In response to Re: ALTER TABLE with TYPE serial does not work  (Richard Broersma <richard.broersma@gmail.com>)
Responses Re: ALTER TABLE with TYPE serial does not work  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Re: ALTER TABLE with TYPE serial does not work  (Osvaldo Kussama <osvaldo.kussama@gmail.com>)
Re: ALTER TABLE with TYPE serial does not work  (Andreas Wenk <a.wenk@netzmeister-st-pauli.de>)
List pgsql-general
On Sat, Jan 31, 2009 at 9:04 PM, Richard Broersma
<richard.broersma@gmail.com> wrote:
> On Sat, Jan 31, 2009 at 3:16 PM, Andreas Wenk
> <a.wenk@netzmeister-st-pauli.de> wrote:
>
>> Why does this not work:
>>
>> postgres=# ALTER TABLE tab1 ALTER COLUMN nr TYPE serial;
>> ERROR:  type "serial" does not exist
>
> serial is really just "short-hand" for making an integer column use
> default incrementing function.  The following will fully explain what
> it is so that you can alter the column:
> http://www.postgresql.org/docs/8.3/interactive/datatype-numeric.html#DATATYPE-SERIAL

Seeing as it works with adding a column, and I've seen instructions
for creating a sequence, and then adding a dependency into the system
tables, it's quite reasonable to expect that one day it will work with
alter table alter column.  But it's probably more complicated than
just making it a serial type, there's probably some question of
setting the sequence according to the max value in the table.  I'd be
surprised if it's not on the TODO list somewhere.

pgsql-general by date:

Previous
From: A B
Date:
Subject: How to catch the id in a INSERT INTO ... RETURNING function?
Next
From: Dean Rasheed
Date:
Subject: Re: Pet Peeves