最新消息: 新版网站上线了!!!

mysql用命令给表加前缀

  1. SET @database = "database_name"
  2. SET @prefix   = "prefix_"
  3.   
  4. SELECT 
  5.     concat( 
  6.         "RENAME TABLE "
  7.         TABLE_NAME, 
  8.         " TO "
  9.         @prefix, 
  10.         TABLE_NAME, 
  11.         ';' 
  12.     ) AS "SQL" 
  13. FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database

实列

复制结果执行 就批量更改了
RENAME TABLE catalog TO prefix_catalog;
RENAME TABLE employee TO prefix_employee;
RENAME TABLE haha_member TO prefix_haha_member;
RENAME TABLE item TO prefix_item;
RENAME TABLE op2mro445_commentmeta TO prefix_op2mro445_commentmeta;
RENAME TABLE page TO prefix_page;
RENAME TABLE page_history TO prefix_page_history;
RENAME TABLE tbl_makanan TO prefix_tbl_makanan;
 
.....

转载请注明:谷谷点程序 » mysql用命令给表加前缀