Обсуждение: Find and Replace All

Поиск
Список
Период
Сортировка

Find and Replace All

От
chelsea boot
Дата:
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.

Re: Find and Replace All

От
Дата:
> 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

Re: Find and Replace All

От
chelsea boot
Дата:
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@yahoo.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.

Re: Find and Replace All

От
Sean Davis
Дата:


On 3/17/06 8:25 AM, "chelsea boot" <scx6148@yahoo.co.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