Search Postgresql Archives

Re: ALTER TABLE with TYPE serial does not work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Scott Marlowe schrieb:
On Sat, Jan 31, 2009 at 9:04 PM, Richard Broersma
<richard.broersma@xxxxxxxxx> wrote:
On Sat, Jan 31, 2009 at 3:16 PM, Andreas Wenk
<a.wenk@xxxxxxxxxxxxxxxxxxxxxxx> 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.

Thanks for this Scott. For me as a user it would be cool to have it ... hopefully it's on a TODO list ;-).

On the other hand I don't think that this case will show up too often because the decision to have a column in a table with a incrementing sequence should be made while designing the database structure ...

Cheers

Andy

--
St.Pauli - Hamburg - Germany

Andreas Wenk


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux