在MySQL中,如何在数据库中批量重命名表? [英] In MySQL, how do I batch rename tables within a database?

查看:446
本文介绍了在MySQL中,如何在数据库中批量重命名表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上,我在MySQL中有一个joomla数据库,该数据库具有一堆带有前缀'jmla_'的表.我想通过将'jmla_'前缀替换为'jos_'前缀来重命名所有这些表.关于如何通过简单的SQL脚本或SQL查询执行此操作的任何想法?

So basically I have a joomla database in MySQL which has a bunch of tables that have the prefix 'jmla_'. I would like to rename all of these tables by replacing the 'jmla_' prefix with a 'jos_' prefix. Any ideas about how to do this with a simple SQL script or SQL query?

推荐答案

SELECT  concat ('rename table ',table_name,' to ',table_name,'_old;')
FROM information_schema.tables
WHERE table_name like 'webform%'
  and table_schema='weiss_db_new'

将起作用.

这篇关于在MySQL中,如何在数据库中批量重命名表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆