Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YbZNr-0000j9-U5 for pgsql-sql@arkaria.postgresql.org; Fri, 27 Mar 2015 18:53:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YbZNq-00057c-Vy for pgsql-sql@arkaria.postgresql.org; Fri, 27 Mar 2015 18:53:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YbZNn-0004zj-S4 for pgsql-sql@postgresql.org; Fri, 27 Mar 2015 18:53:28 +0000 Received: from resqmta-ch2-09v.sys.comcast.net ([2001:558:fe21:29:69:252:207:41]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YbZNj-0008G6-Kq for pgsql-sql@postgresql.org; Fri, 27 Mar 2015 18:53:25 +0000 Received: from resomta-ch2-05v.sys.comcast.net ([69.252.207.101]) by resqmta-ch2-09v.sys.comcast.net with comcast id 8isq1q0012Bo0NV01itN2U; Fri, 27 Mar 2015 18:53:22 +0000 Received: from jerry.enova.com ([12.30.159.20]) by resomta-ch2-05v.sys.comcast.net with comcast id 8itA1q0030ShjPw01itCT6; Fri, 27 Mar 2015 18:53:20 +0000 Received: by jerry.enova.com (Postfix, from userid 1001) id C85FD7401EB; Fri, 27 Mar 2015 13:53:09 -0500 (CDT) From: Jerry Sievers To: Suresh Raja Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [GENERAL] check data for datatype References: Date: Fri, 27 Mar 2015 13:53:09 -0500 In-Reply-To: (Suresh Raja's message of "Fri, 27 Mar 2015 13:08:43 -0500") Message-ID: <86vbhm2rxm.fsf@jerry.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1427482402; bh=dEAeRRDIssGAGTSE9pFWXEpDT2Ihyz6MPSzZoIBntgo=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=kurlUGpZ3CWe2VxzrQn8W+jkzgv+Kd3ui0axozyUJ4Kmx0Kz4j8QxqWbtlt3JT49q EWNStToFhKuDnMDWcUw9bdmkQbZVLN9AY8eXpFSw/shazRjoU4G2cd1GmpjTD/y+uT zKZJUias0r8Wq10SkNO8sapid1nrlQL7j700sFtR88BEFfKF6/LcZE/2V8GZNI/7pj f1umr5+39QbUgLuW9IqYZ/Tnq9VQjvMWR2x+sa4PMPWZ3nHsjkcJuHtdUhvZjQi5aX L+qPYsQ9Aa/DG1maGcBGeGXuiusmf99xoI5xSihU6cKRKm5Y/8kdTyh2G9Fg0AsVrI gwOVorDCLMcqg== X-Pg-Spam-Score: -1.5 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Suresh Raja writes: > Hi All: > > I have a very large table and the column type is text.  I would like to convert in numeric.  How can I find rows that dont have numbers.  I would like to delete those > rows. begin; set local client_min_messages to notice; create table foo (a text); copy foo from stdin; 1 foo \. create function foo (text) returns numeric as $$ begin return $1::numeric; exception when invalid_text_representation then raise notice '%: %', sqlstate, sqlerrm; return 'nan'; end $$ language plpgsql; alter table foo alter a type numeric using foo(a); select * from foo; --now go delete your 'nan rows abort; > > Thanks, > -Suersh Raja > -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql