alter table serial->int - Mailing list pgsql-admin

From Erik Aronesty
Subject alter table serial->int
Date
Msg-id ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com
Whole thread Raw
Responses Re: alter table serial->int
List pgsql-admin
for some odd reason when i try to change a table fromserial to just
plain "int with a default" postgres seems to ignore me.

when i dump the schema i get ...

CREATE TABLE custom (
    id serial NOT NULL,
    name text,
    email text,
);

then i run...

alter table custom alter id type int;
alter table custom alter id set default
((nextval('custom_seq'::regclass) * 100) + ((random() * (100)::double
precision))::integer);

after running these 2 alter table commands... i dump the schema ...
and voila... nothing happened....

CREATE TABLE custom (
    id serial NOT NULL,
    name text,
    email text,
);


or did it? the change actually works... i see the new slightly
randomized ids going in nicely

my only problem is that backups aren't going to restore correctly
since the schema dumps wrong

pgsql-admin by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: Re: Source of pgpool2 manual
Next
From: "j a"
Date:
Subject: Re: Vacuum Doesn't Recover Disk Space