alter table serial->int

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

 



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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux