From siu_keith@hotmail.com Sun Aug 22 09:47:32 2004 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 C56425E4249 for ; Sun, 22 Aug 2004 06:47:32 -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 96045-09 for ; Sun, 22 Aug 2004 09:47:27 +0000 (GMT) Received: from hotmail.com (bay12-dav10.bay12.hotmail.com [64.4.35.184]) by svr1.postgresql.org (Postfix) with ESMTP id C323A5E40BA for ; Sun, 22 Aug 2004 06:47:25 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 22 Aug 2004 02:47:28 -0700 Received: from 210.184.255.200 by bay12-dav10.bay12.hotmail.com with DAV; Sun, 22 Aug 2004 09:47:28 +0000 X-Originating-IP: [210.184.255.200] X-Originating-Email: [siu_keith@hotmail.com] X-Sender: siu_keith@hotmail.com From: "Keith" To: Subject: add serial no Date: Sun, 22 Aug 2004 17:47:17 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0038_01C48870.11019E90" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: X-OriginalArrivalTime: 22 Aug 2004 09:47:28.0385 (UTC) FILETIME=[09483710:01C4882D] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/236 X-Sequence-Number: 14631 This is a multi-part message in MIME format. ------=_NextPart_000_0038_01C48870.11019E90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable 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 pos= ted.=20 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 transl= ate '1234' to 'one thousand two hundred thirty four'.. Pls help. regards ------=_NextPart_000_0038_01C48870.11019E90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
Dear All,
 
Someone can help me to solve the below=20 problems
 
1. I create a table for a period= of time,=20 there is huge records already posted.
I would like to alter table and add serial= primary=20 key on that table.  It's impossible to add serial no by hand. Ple= ase=20 adv  how can I add the serial number automatically.
 
2. Is there any library to translate digit= number=20 to English, I mean translate '1234' to 'one thousand two hundred thirty fou= r'..=20 Pls help.
 
regards
------=_NextPart_000_0038_01C48870.11019E90-- From uwe@oss4u.com Tue Aug 24 18:43:19 2004 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 5B2A95E40AC for ; Tue, 24 Aug 2004 15:43:19 -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 14792-06 for ; Tue, 24 Aug 2004 18:43:14 +0000 (GMT) Received: from pop.sanbrunocable.com (pop.sanbrunocable.com [65.172.230.120]) by svr1.postgresql.org (Postfix) with ESMTP id 6CE5C5E37D0 for ; Tue, 24 Aug 2004 15:43:13 -0300 (ADT) Received: from oss4u.com (cpe-65-172-234-54.sanbrunocable.com [65.172.234.54]) by pop.sanbrunocable.com (8.11.6/8.11.6) with SMTP id i7OIg1J01255 for ; Tue, 24 Aug 2004 11:42:01 -0700 Received: (qmail 6241 invoked from network); 24 Aug 2004 18:38:54 -0000 Received: from tiburon.oss4u.com (192.168.1.4) by gw.oss4u.com (192.168.1.1) with ESMTP; 24 Aug 2004 18:38:54 -0000 From: "Uwe C. Schroeder" Organization: OSS4U, LLC To: "Keith" , Subject: Re: add serial no Date: Tue, 24 Aug 2004 11:43:08 -0700 User-Agent: KMail/1.5.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="big5" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200408241143.08959.uwe@oss4u.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/240 X-Sequence-Number: 14635 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 22 August 2004 02: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 a= dd > the serial number automatically. Create a table with the same structure as your original table, just add a sid int4 serial column to it. (sid can be any column name you want it to be) The serial col= umn=20 has to be at the end! Then do a INSERT INTO SELECT FROM The serial column will automatically be set to 1,2,3,4,5 etc. After that check if all the data made it to the new table and then you can= =20 drop the old table and rename the new table to the name of the old table. As usual I'd make a backup of the original table before doing all this. > 2. Is there any library to translate digit number to English, I mean > translate '1234' to 'one thousand two hundred thirty four'.. Pls help. Sorry, can't help with that one. UC - -- Open Source Solutions 4U, LLC 2570 Fleetwood Drive Phone: +1 650 872 2425 San Bruno, CA 94066 Cell: +1 650 302 2405 United States Fax: +1 650 872 2417 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFBK4w8jqGXBvRToM4RAm5MAJ0c5ygo1V9ISdn7nOy51rHazWbnDACg0QBF 1nlwxalbrc8vVb64dxk7QgE=3D =3Dhi8w -----END PGP SIGNATURE----- From mendola@bigfoot.com Tue Aug 24 21:31:31 2004 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 162935E46C2 for ; Tue, 24 Aug 2004 18:31:31 -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 92172-04 for ; Tue, 24 Aug 2004 21:31:25 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 930F25E40BA for ; Tue, 24 Aug 2004 18:31:24 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7OLVOLq093952 for ; Tue, 24 Aug 2004 21:31:24 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7OL7Cla084870 for pgsql-admin@postgresql.org; Tue, 24 Aug 2004 21:07:13 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.admin Subject: Re: add serial no Date: Tue, 24 Aug 2004 23:07:09 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 53 Message-ID: <412BADFD.5030903@bigfoot.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: Keith User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-admin@postgresql.org 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/242 X-Sequence-Number: 14637 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. Just to inform you that with the future 8.0 postgresl version you can do this task easily: kalman=# select * from test; field_1 --------- 3 5 7 6 8 (5 rows) kalman=# alter table test add column pk serial primary key; NOTICE: ALTER TABLE will create implicit sequence "test_pk_seq" for serial column "test.pk" NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "test_pkey" for table "test" ALTER TABLE kalman=# select * from test; field_1 | pk ---------+---- 3 | 1 5 | 2 7 | 3 6 | 4 8 | 5 (5 rows) Regards Gaetano Mendola From scrawford@pinpointresearch.com Tue Aug 24 21:48:46 2004 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