X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 69AA95E46CE for ; Tue, 24 Aug 2004 18:48:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99511-03 for ; Tue, 24 Aug 2004 21:48:42 +0000 (GMT) Received: from polaris.pinpointresearch.com (66-7-238-130.cust.telepacific.net [66.7.238.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0F1EF5E46C1 for ; Tue, 24 Aug 2004 18:48:40 -0300 (ADT) Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 9682010435; Tue, 24 Aug 2004 14:48:42 -0700 (PDT) From: Steve Crawford Organization: Pinpoint Research To: "Keith" , Subject: Re: add serial no Date: Tue, 24 Aug 2004 14:48:42 -0700 User-Agent: KMail/1.5.1 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200408241448.42337.scrawford@pinpointresearch.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/243 X-Sequence-Number: 14638 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