如何更改我的MySQL数据库中的所有表中的前缀? [英] How I can change prefixes in all tables in my MySQL DB?
本文介绍了如何更改我的MySQL数据库中的所有表中的前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的供应商安装到我的网站Drupal CMS。现在我需要从旧站点复制我的所有数据。我在旧的DB中有没有前缀的表,但在新的DB中,所有表都有dp_ [table_name]前缀。
My provider installed to my site Drupal CMS. Now I need copy all my data from old site. I have tables without prefixes in my old DB, but in new DB all tables have "dp_[table_name]" prefix.
推荐答案
写一个将为每个表运行RENAME TABLE的脚本。
write a script that will run RENAME TABLE for each table.
SELECT
GROUP_CONCAT('RENAME TABLE `', TABLE_SCHEMA, '`.`', TABLE_NAME, '` TO `', TABLE_SCHEMA, '`.`prefix_', TABLE_NAME, '`;' SEPARATOR ' ')
FROM
`TABLES` WHERE `TABLE_SCHEMA` = "test";
其中test是预期的数据库名称
where "test" is expected database name
之后,你可以长查询,如果你执行它将添加前缀; - )
after this you can long query that will add prefixes if you execute it ;-)
这篇关于如何更改我的MySQL数据库中的所有表中的前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文