pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tony Yang <gnalesad@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: help with scheme changes to live system.
Date: Thu, 19 Aug 2004 22:00:56 +0000
Message-ID: <BAY1-F34ktJ3GOeym8Y000966ee@hotmail.com> (raw)

Hi Gurus,

Please forgive this naive question:

Say, I have a table (containerId, itemId) where for each containerId there 
are several rows (different itemId value) in that table. Now I want to give 
those rows (with same containerId) a sequence, so add one colum there to 
make it become (containerId, itemId, sequence);  how do I make such changes 
through SQL?

I know how to alter the table to insert that new column, but how do I 
populate the existed rows on that new column? note the sequence dose not 
need to confirm to any sorting of other columns, i.e., as long as there is a 
sequence is ok. for example, if I already have :

containerId  | itemId  |
1                     1001
1                     1002
1                     1003
2                     2001
2                     2002

then either

containerId  | itemId  |  sequence
1                     1001         0
1                     1002         1
1                     1003         2
2                     2001         1
2                     2002         0

or

containerId  | itemId  |  sequence
1                     1001         2
1                     1002         1
1                     1003         0
2                     2001         0
2                     2002         1

are all OK.

Thanks,
Gnale

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




Message-ID: <BAY1-F34ktJ3GOeym8Y000966ee@hotmail.com>
Permalink:  ../BAY1-F34ktJ3GOeym8Y000966ee@hotmail.com/
Also on:    postgresql.org/message-id/BAY1-F34ktJ3GOeym8Y000966ee@hotmail.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-sql@postgresql.org
  Cc: gnalesad@hotmail.com
  Subject: Re: help with scheme changes to live system.
  In-Reply-To: <BAY1-F34ktJ3GOeym8Y000966ee@hotmail.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