Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 508DD1337BA4 for ; Tue, 15 Feb 2011 17:10:24 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 93333-05 for ; Tue, 15 Feb 2011 21:10:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id BA5F31337B90 for ; Tue, 15 Feb 2011 17:10:16 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p1FLAGd7010591; Tue, 15 Feb 2011 16:10:16 -0500 (EST) To: Tony Capobianco cc: pgsql-sql@postgresql.org Subject: Re: Determine length of numeric field In-reply-to: <1297802915.1703.13.camel@tony1.localdomain> References: <1297802915.1703.13.camel@tony1.localdomain> Comments: In-reply-to Tony Capobianco message dated "Tue, 15 Feb 2011 15:48:35 -0500" Date: Tue, 15 Feb 2011 16:10:16 -0500 Message-ID: <10590.1297804216@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/68 X-Sequence-Number: 35144 Tony Capobianco writes: > I'm altering datatypes in several tables from numeric to integer. In > doing so, I get the following error: > dw=# \d uniq_hits > Table "support.uniq_hits" > Column | Type | Modifiers > ------------+---------+----------- > sourceid | numeric | > hitdate | date | > total | numeric | > hitdate_id | integer | > Indexes: > "uniq_hits_hitdateid_idx" btree (hitdate_id), tablespace > "support_idx" > Tablespace: "support" > esave_dw=# alter table uniq_hits alter sourceid type int; > ERROR: integer out of range > Sourceid should not be more than 5 digits long. I'm able to perform > this query on Oracle and would like something similar on postgres 8.4: > delete from uniq_hits where sourceid in (select sourceid from uniq_hits > where length(sourceid) > 5); That seems like a pretty bizarre operation to apply to a number. Why not "where sourceid > 99999"? Or maybe "where abs(sourceid) > 99999" would be better. regards, tom lane