| 功能比较实用,该magento中批量添加修改删除表前缀方法,在magento维护当中经常用到 1.写批处理语句change_prefix.sql,内容如下:
delimiter // DROP procedure IF EXISTS change_prefix // CREATE procedure change_prefix(IN oldpre VARCHAR(200), IN newpre VARCHAR(200), IN dbname VARCHAR(200)) begin declare done INT DEFAULT 0; declare oldname VARCHAR(200); declare cur CURSOR FOR SELECT table_name FROM information_schema.TABLES WHERE table_schema= dbname AND table_name LIKE concat(oldpre,'%'); declare continue handler FOR NOT found SET done = 1; open cur; repeat fetch cur INTO oldname; IF NOT done then SET @newname = concat(newpre, trim(LEADING oldpre FROM oldname)); SET @sql = concat('rename table ',oldname,' to ',@newname); prepare tmpstmt FROM @sql; execute tmpstmt; deallocate prepare tmpstmt; end IF; until done end repeat; close cur; end // delimiter ;
2.命令行登录mysql执行以下操作:
-- use magento; -- show tables; -- source /home/change_prefix.sql; -- -- call change_prefix('', 'mdb_', 'magento'); -- -- show tables; -- drop procedure if exists change_prefix; --
参数说明:第一个参数是:原数据库表前缀,留空表示无前缀 第二个参数是:你要修改的新前缀,留空表示取消所有表前缀 第三个参数是:你的数据库名 call change_prefix(‘oldprefix_’,‘newprefix_’, ‘DB_NAME’); 3.重新安装magento,数据库还用magento,用户信息不变,记得填写数据库表前缀,要写成你刚才添加的那个前缀。 (责任编辑:最模板) |

ecshop仿米奇网化妆品2014网
人气:549
空包网刷快递单号自动发
人气:3467
Milano外贸Prestasop商城模板
人气:306
ecshop仿易迅51buy模板|ecsh
人气:4292
ecshop手表英文外贸模板
人气:1282
ecshop红色综合商城(推荐
人气:1599