Changing a database table prefix is easy and here’s the simple step-by-step guide! For WordPress installations, it’s essential!
database_name
, old_prefix_
and new_prefix_
to the required values:SET @database = "database_name" ; SET @old_prefix = "old_prefix_" ; SET @new_prefix = "new_prefix_" ; SELECT concat( "RENAME TABLE " , TABLE_NAME, " TO " , replace(TABLE_NAME, @old_prefix, @new_prefix), ';' ) AS "SQL" FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database; |
If your database doesn’t have a prefix at all, follow the steps above but use the below query that’s been slightly modified for this purpose:
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; |
See how easy that was? Isn’t it great when articles just get straight to the point? :)
제목 | 날짜 | ||
---|---|---|---|
14 | [MySQL] MySQL/MariaDB 디비 튜닝하기 | 0 | 2017/06/25 |
[MySQL] How to change a MySQL database’s table prefix | 59 | 2020/02/18 | |
12 | [MySQL] MySQL 명령어 | 74 | 2017/03/15 |
11 | [MySQL] Mysql 프리픽스 수정하기 | 92 | 2017/03/15 |
10 | [MySQL] MySQL 사용자 테이블 생성 및 연결하기 | 93 | 2018/06/24 |
9 | [MySQL] phpmyadmin, adminer 접속 불가능.. | 93 | 2018/12/03 |
8 | [MySQL] 테이블명 교체하기 쿼리문 | 96 | 2017/03/15 |
7 | [MySQL] MySQL 기본적인 사용방법 | 143 | 2017/10/20 |
6 | [MySQL] Mysql Join 해부(Left, Right, Outer, Inner Join) | 154 | 2018/01/03 |
5 | [MySQL] mysql autorepair / MySQL 자동복구 | 272 | 2017/07/03 |
4 | [MySQL] my.cnf 동접자수 설정 / 튜닝 | 302 | 2017/06/26 |
3 | [MySQL] phpmyAdmin을 대체하는 Adminer - myadmin | 525 | 2017/04/12 |