1. Adding a prefix to all tables in a MySQL database

SELECT Concat('ALTER TABLE ', TABLE_NAME, ' RENAME TO my_prefix_', TABLE_NAME, ';') FROM information_schema.tables WHERE table_schema = 'my_database'

출처 : https://steindom.com/articles/adding-prefix-all-tables-mysql-database

2.

SELECT 
  GROUP_CONCAT('RENAME TABLE `', TABLE_SCHEMA, '`.`', TABLE_NAME, '` TO `', TABLE_SCHEMA, '`.`prefix_', TABLE_NAME, '`;' SEPARATOR ' ')
FROM 
  `TABLES` WHERE `TABLE_SCHEMA` = "test";

참조

http://stackoverflow.com/questions/16339636/how-to-change-all-table-prefix-in-a-single-query

http://stackoverflow.com/questions/2466101/how-i-can-change-prefixes-in-all-tables-in-my-mysql-db

3. How to change a MySQL database’s table prefix

https://richjenks.com/change-mysql-database-table-prefix/

https://sir.kr/qa/145401

 
댓글은 로그인 사용자만 작성 가능합니다. 로그인하기