Wednesday 15 April 2015

sql - Replacement throughout the database MYSQL -


I am looking to change all the occurrences of characters in all the columns of all tables in my database.

I found the name of my column like this:

Select table_name, column_name from info_schema.column;

And I will apply it to an updated location like this:

Update table_name set column_name = (column_name, "a", "a");

PS: Replacement of "A" from "A" is just an example, my problem is how do I link table_name and column_name between my two questions.

I tried with subdivision, such as:

Set update (choose table_name from information_schema.tables as table) (Select column_name from column as info_schema.column ) Where table_name = tables) = replacement (column, "A", "A");

But whenever I try, I get errors, what is the right way to do this?

Thank you in advance.

You need a stored procedure that searches for all the tables and columns in your database Information_schema , and will execute the update statement for all these tables.

Look at the following questions at a glance which really answers what you want to do:

No comments:

Post a Comment