Shonna
Shonna

Reputation: 289

Search & Replace SQL

I am messing around with one of my databases.. is there away for me to search for a string in ALL the tables.. and replace it with another everywhere it occurs?

I am looking for SQL

Upvotes: 1

Views: 385

Answers (2)

Unreason
Unreason

Reputation: 12704

There is no immediate SQL to do this, databases are not flat text files.

If you are trying to learn something follow OMG Ponies advice.

Alternatively, searching google for terms: mysql search and replace all tables gives as a first result on a first page a helpful discussion.

Upvotes: 1

OMG Ponies
OMG Ponies

Reputation: 332771

You need to use MySQL's Prepared Statements to do this, because first you need a list of tables by querying INFORMATION_SCHEMA. This list is string data types, which you can not immediately use as the FROM clause in subsequent queries.

Upvotes: 2

Related Questions