myql 批量生成替换表前缀sql语句

1.查询所有表

select table_name FROM information_schema.tables;

2.查询指定前缀的表

select table_name FROM information_schema.tables where table_name like ‘go_%’;

3.生成从指定位置开始替换表名的sql语句(”3″表示从”go_”后面开始)

Select CONCAT( ‘ALTER TABLE ‘, table_name, ‘ RENAME TO xm_’, substring(table_name,3),’;’ )FROM information_schema.tables Where table_name LIKE ‘go_%’;

 

将生成的重命名语句语句复制出来,拿去执行,OK

发表评论