Select CONCAT( 'ALTER TABLE ', table_name, ' RENAME TO jh_', substring(table_name,6 ),';' )FROM information_schema.tables Where table_name LIKE '33hao_%';
想把数据库名为jh中的表前缀为33hao_的换成前缀为jh_
执行上面的代码后ALTER 出很多句子,但在执行这些ALTER句子时出现错误,如下
[SQL]ALTER TABLE 33hao_activity RENAME TO jh__activity;
[Err] 1146 - Table 'jh.33hao_activity' doesn't exist
不知哪里写错了
Underscore is also a wildcard character and should be escaped, otherwise some tables that are not prefixed with 33hao_ will also be included
Is the database used wrong? Does the jh database really have the table 33hao_activity?