Re: How to get a list of tables that have a particular column value?

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "Rajan, Pavithra " <RAJANP(at)coned(dot)com>
Subject: Re: How to get a list of tables that have a particular column value?
Date: 2009-12-24 21:46:50
Message-ID: 200912241346.50726.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 24 December 2009 5:35:10 am Rajan, Pavithra wrote:
> Hello -Yes I need to find out the column value like '%Volt%' in any
> column of data_type (character varying) of any table. Basically what I
> need to do is go thro each columns of all tables and find any entries
> that have Voltage followed by some number e.g. 'Voltage 4.8000'.Then I
> need to use regexep_replace function to curtail the precision to two
> digits after decimal instead of 4.
>
> Eg:table name 'app' has a column name description which has 4 entries
> like
>
> | description |
> | character varying(50) |
> |
> | Voltage 2.4000 |
> | Voltage 4.8000 |
> | Voltgae 3.0509 | |
> | Voltage 1.0010 |
>
> Then I run a sql file with this command any many other Update commands
> form other tables that have similar entries in various columns.
>
> UPDATE app SET app = regexp_replace(description,'4.8000','4.80') where
> description like 'Volt%';
>
> Hence I need to know all the tables and their column name ("data_type
>
> :character varying") that has this 4 digit extn.
>
> Thank you.
>
>

Would it not be easier to dump the data and does this against the text dump and
then restore the data?

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2009-12-24 21:53:25 Re: cross-database time extract?
Previous Message Israel Brewster 2009-12-24 21:44:58 cross-database time extract?