Subject: alter table serial->int
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/7/2007 12:11:10 AM
"Erik Aronesty" <erik@q32.com> writes:
> for some odd reason when i try to change a table fromserial to just
> plain "int with a default" postgres seems to ignore me.
What PG version?
I'd expect this to work somewhat sanely in 8.2, but in earlier versions
fooling with the default expression for a serial column is not well
supported.
> alter table custom alter id type int;
The fact that you even tried that suggests that you don't understand
very well what "serial" is. See the manual ...
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Subject: alter table serial->int
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 11/11/2007 10:37:11 AM
"Erik Aronesty" <erik@q32.com> writes:
> alter table x alter a set default 999;
> still doesn't help.
Doesn't help what?
If you mean that the sequence object is still there, you can drop that too.
regression=# create table x(a serial not null);
NOTICE: CREATE TABLE will create implicit sequence "x_a_seq" for serial column "x.a"
CREATE TABLE
regression=# drop sequence x_a_seq;
NOTICE: default for table x column a depends on sequence x_a_seq
ERROR: cannot drop sequence x_a_seq because other objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.
regression=# alter table x alter a set default 999;
ALTER TABLE
regression=# drop sequence x_a_seq;
DROP SEQUENCE
regression=# \d x
Table "public.x"
Column | Type | Modifiers
--------+---------+----------------------
a | integer | not null default 999
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
|