pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Aronesty <erik@q32.com>
To: pgsql-admin@postgresql.org
Subject: alter table serial->int
Date: Tue, 6 Nov 2007 16:59:44 -0500
Message-ID: <ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com> (raw)

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



view thread (8+ messages)  latest in thread

Message-ID: <ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com>
Permalink:  ../ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com/
Also on:    postgresql.org/message-id/ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: erik@q32.com
  Subject: Re: alter table serial->int
  In-Reply-To: <ccd588d90711061359m57d95921mc28b74dec9f35f54@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox