vendredi 26 mai 2017

Is there a way in MySQL to execute a result set from information_schema

This gives me a list of queries I would like to execute:

select CONCAT('ALTER TABLE ',table_name,' DROP edit_time;') AS query FROM information_schema.COLUMNS    where column_name = 'edit_time' AND table_schema = 'homestead';

Result:

|query|
ALTER TABLE node_fields DROP edit_time;
ALTER TABLE node_list_role DROP edit_time;
ALTER TABLE node_list_versions DROP edit_time;
ALTER TABLE node_lists DROP edit_time;
.. (etc) ..

This returns rows of all tables that I want to drop that field on. But is there any way to do something like:

EXECUTE {that query}

or

FOREACH {results of that query} EXECUTE( {that row} )

I don't know mysql procedures or logical statements that well so this is new to me.

Aucun commentaire:

Enregistrer un commentaire