Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 18ABE1337B90 for ; Tue, 15 Feb 2011 16:55:24 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 65811-03 for ; Tue, 15 Feb 2011 20:55:16 +0000 (UTC) X-Greylist: delayed 00:06:39.547284 by SQLgrey-1.7.6 Received: from stan.prospectivdirect.com (mail.prospectiv.com [155.212.59.212]) by mail.postgresql.org (Postfix) with SMTP id 61DE31337B8C for ; Tue, 15 Feb 2011 16:55:16 -0400 (AST) Received: (qmail 19448 invoked from network); 15 Feb 2011 20:48:35 -0000 Received: from unknown (HELO ?192.168.1.87?) (192.168.1.87) by 0 with SMTP; 15 Feb 2011 20:48:35 -0000 Subject: Determine length of numeric field From: Tony Capobianco To: pgsql-sql@postgresql.org Content-Type: text/plain; charset="UTF-8" Date: Tue, 15 Feb 2011 15:48:35 -0500 Message-ID: <1297802915.1703.13.camel@tony1.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) Content-Transfer-Encoding: 7bit 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/64 X-Sequence-Number: 35140 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); I haven't had much luck with the length or char_length functions on postgres. Thanks. Tony