Re: serial type question

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: postgresql <pgsql(at)symcom(dot)com>
Cc: PgSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: serial type question
Date: 2001-03-19 19:34:15
Message-ID: Pine.BSF.4.21.0103191128410.26001-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Mon, 19 Mar 2001, postgresql wrote:

> I have a table that I want to add a serial type column. Is there a way
> to add it or do I have to create a new table and insert into it. I have
> experimented with:
>
> insert into newdb (name) select name from olddb order by jobno;
>
> however, pg does not allow the 'order by' during an insert/select
>
> I am on version 7.0.3

The type of query above seems to work in 7.1, but...

> Maybe I don't need to do this. What I am trying to accomplish is to
> have PG create job numbers. Today, I only have 2 workstations that
> push jobs into the server and PG tracks the job number. However, I
> have been informed that in the next 6-8 months the number of job
> creation workstations will grow to 8 - 10.
>
> I would like to migrate to a job number created when the insert is
> done.

Because serial only is a column with a default gathered from a sequence,
if you can just use the jobno's from the old table, I'd say you
just might want to make it, load the jobno's you already have and set the
sequence value higher than those, new rows will get new automatic jobno's
and the old ones will keep their values.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Daryl Herzmann 2001-03-19 19:46:10 Maybe a Bug, maybe bad SQL
Previous Message Josh Berkus 2001-03-19 19:15:01 Re: What do I do with this error?