mysql - How to change all table prefix in a single query -
i pretty amateur in mysql..can please tell me how can change table prefixes of whole database in single query... can manually, quite time consuming change tables prefixes. please me out. isc_administrator_log cus_administrator_log means isc_ cus_
i found these 2 solutions not understand either of them.
select group_concat('rename table `', table_schema, '`.`', table_name, '` `', table_schema, '`.`prefix_', table_name, '`;' separator ' ') `tables` `table_schema` = "test";
and
select concat('rename table ', group_concat('`', table_schema, '`.`', table_name, '` `', table_schema, '`.`prefix_', table_name, '`')) q `information_schema`.`tables` table_schema='test';
you can dynamic sql query mysql 5.0.13
delimiter // create procedure dynamic(in tbl char(64), in col char(64)) begin set @s = concat('select 'rename table ', group_concat('', table_schema, ''
.'', table_name, '
', table_schema, ''='
.prefix_''', table_name, '
')) q information_schema
.tables
table_schema='test'';;' prepare stmt @s; execute stmt; end // delimiter ;
got reference here
Comments
Post a Comment