From: Steve Crawford <scrawford@pinpointresearch.com>
To: Keith <siu_keith@hotmail.com>
To: pgsql-admin@postgresql.org
Subject: Re: add serial no
Date: Tue, 24 Aug 2004 14:48:42 -0700
Message-ID: <200408241448.42337.scrawford@pinpointresearch.com> (raw)
In-Reply-To: <BAY12-DAV10Jgzg8MTb000098bb@hotmail.com>
References: <BAY12-DAV10Jgzg8MTb000098bb@hotmail.com>
On Sunday 22 August 2004 2:47 am, Keith wrote:
> Dear All,
>
> Someone can help me to solve the below problems
>
> 1. I create a table for a period of time, there is huge records
> already posted. I would like to alter table and add serial primary
> key on that table. It's impossible to add serial no by hand.
> Please adv how can I add the serial number automatically.
>
> 2. Is there any library to translate digit number to English, I
> mean translate '1234' to 'one thousand two hundred thirty four'..
> Pls help.
>
> regards
Going from memory (and note, this will only give you unique numbers -
they won't be in any specific order)...
create sequence foo_sequence;
alter table foo add column (serialnumber bigint);
alter table foo alter column serialnumber set default
nextval('foo_sequence');
update foo set serialnumber = nextval('foo_sequence') where
serialnumber is null;
alter table foo alter column serialnumber set not null;
Cheers,
Steve
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: scrawford@pinpointresearch.com, siu_keith@hotmail.com
Subject: Re: add serial no
In-Reply-To: <200408241448.42337.scrawford@pinpointresearch.com>
References: <BAY12-DAV10Jgzg8MTb000098bb@hotmail.com> <200408241448.42337.scrawford@pinpointresearch.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