- SET @database = "database_name";
- SET @prefix = "prefix_";
- SELECT
- concat(
- "RENAME TABLE ",
- TABLE_NAME,
- " TO ",
- @prefix,
- TABLE_NAME,
- ';'
- ) AS "SQL"
- 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用命令给表加前缀