Re: Find and Replace All

Lists: pgsql-novice
From: chelsea boot <scx6148(at)yahoo(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Find and Replace All
Date: 2006-03-16 20:46:57
Message-ID: 20060316204657.27620.qmail@web86810.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi

Is there a way to update multiple tables with the same information? A kind of MS "find and replace all" utility. I want to change the drive letter of a filepath that is listed in one or more columns of several tables.

Thanks


---------------------------------
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo.


From: <operationsengineer1(at)yahoo(dot)com>
To: chelsea boot <scx6148(at)yahoo(dot)co(dot)uk>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Find and Replace All
Date: 2006-03-16 21:10:02
Message-ID: 20060316211002.81736.qmail@web33309.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> Hi
>
> Is there a way to update multiple tables with the
> same information? A kind of MS "find and replace
> all" utility. I want to change the drive letter of
> a filepath that is listed in one or more columns of
> several tables.
>
> Thanks

i'm no expert, but i'll bite. yes, you could do that
if you set up a program to run the SQL on all the
tables.

it would probably be easier to just run the SQL on the
individual tables, though. i'd use pgadminIII.

do you need help with the SQL?

ps - is your pgsql crash problem on winxp?

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


From: chelsea boot <scx6148(at)yahoo(dot)co(dot)uk>
To: operationsengineer1(at)yahoo(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: Find and Replace All
Date: 2006-03-17 13:25:11
Message-ID: 20060317132512.37446.qmail@web86807.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Thanks - I've used PGAdmin to update the tables before but as there is a few of them I wanted to save time. I was looking at the UPDATE command but didn't know how to (1) select only part of a field to update eg. update d:\upkeep\jones to r:\upkeep\jones and (2) search all columns and all tables. Am I looking at the right command?

My postgres crash problem is on Win2K. Any ideas?

operationsengineer1(at)yahoo(dot)com wrote:
> Hi
>
> Is there a way to update multiple tables with the
> same information? A kind of MS "find and replace
> all" utility. I want to change the drive letter of
> a filepath that is listed in one or more columns of
> several tables.
>
> Thanks

i'm no expert, but i'll bite. yes, you could do that
if you set up a program to run the SQL on all the
tables.

it would probably be easier to just run the SQL on the
individual tables, though. i'd use pgadminIII.

do you need help with the SQL?

ps - is your pgsql crash problem on winxp?

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.


From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: chelsea boot <scx6148(at)yahoo(dot)co(dot)uk>, <operationsengineer1(at)yahoo(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Find and Replace All
Date: 2006-03-17 13:31:36
Message-ID: C0402468.85C3%sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On 3/17/06 8:25 AM, "chelsea boot" <scx6148(at)yahoo(dot)co(dot)uk> wrote:

> Thanks - I've used PGAdmin to update the tables before but as there is a few
> of them I wanted to save time. I was looking at the UPDATE command but didn't
> know how to (1) select only part of a field to update eg. update
> d:\upkeep\jones to r:\upkeep\jones and (2) search all columns and all tables.
> Am I looking at the right command?

Updates can only be done on a table-by-table basis. You could write a
script or use a word processor to generate a script to do the updates you
like for each table and then feed that file into psql or just paste it into
the pgAdminIII window.

You cannot update only part of a field. An update can be viewed as a
replacement of an old value with a new one. If you have an old value and
want to replace it with a new one, you will need to find a function that
manipulates the old data to the new. See, for example, here:

http://www.postgresql.org/docs/8.1/interactive/functions-string.html

For the example you give above, look at using replace or concatenate and
trim.

Sean