From: | "Tony Yang" <gnalesad(at)hotmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | help with scheme changes to live system. |
Date: | 2004-08-19 22:00:56 |
Message-ID: | BAY1-F34ktJ3GOeym8Y000966ee@hotmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2004-08-20 02:16:50 | Re: SQL Challenge: Arbitrary Cross-tab |
Previous Message | Jan Wieck | 2004-08-19 21:41:07 | Re: multi column foreign key for implicitly unique columns |