Haim Evgi Haim Evgi - 1 year ago 55
MySQL Question

search simple way to alter multi tables in one time in mysql

i have a lot of tables that start with some prefix ,

and i want to alter this tables

what is the simple way to do this (instead run over all tables)

i mean something like :

ALTER TABLE LIKE tablenameprefix% ADD INDEX `NewIndex1` (`field`);


how can i do this ?

thanks

EDIT :

can i do a kind of loop not in stored procedure ?
by select the names of tables from

SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME LIKE 'tableprefix%'

Answer Source

You can't. What you could do though is write a stored procedure that enumerates all tables looking for your prefix and performs the necessary changes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download