Re: How to get a list of tables that have a particular column value? - Mailing list pgsql-general

From Adrian Klaver
Subject Re: How to get a list of tables that have a particular column value?
Date
Msg-id 200912241346.50726.aklaver@comcast.net
Whole thread Raw
In response to Re: How to get a list of tables that have a particular column value?  ("Rajan, Pavithra " <RAJANP@coned.com>)
List 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@comcast.net

pgsql-general by date:

Previous
From: Israel Brewster
Date:
Subject: cross-database time extract?
Next
From: Raul Giucich
Date:
Subject: Esqsuig(!77. ca ccqyvxxghsqf