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? :)
제목 | 날짜 | ||
---|---|---|---|
95 | [MySQL] Mysql Join 해부(Left, Right, Outer, Inner Join) | 154 | 2018/01/03 |
94 | [리눅스서버] Ubuntu 16.04 | root 계정으로 로그인하기, root 계정으로 ssh 접속하기 | 91 | 2018/03/21 |
93 | [리눅스서버] Ubuntu php7.0-fpm 세팅 중 오류 | 76 | 2018/03/25 |
92 | [리눅스서버] mysql strict mode 끄기 | 888 | 2018/03/29 |
91 | nginx https redirect www to non-www | 231 | 2018/04/04 |
90 | [Nginx] nginx-redirects-http-to-https-and-www-to-non-www | 79 | 2018/04/21 |
89 | [Nginx] https가 아닐 경우 https로 리다이렉트하는 방법 | 170 | 2018/04/25 |
88 | [Nginx] [Nginx] Rewriterule 서브 도메인 입력시 하위 디렉토리로 이동하기 | 501 | 2018/05/15 |
87 | [MySQL] MySQL 사용자 테이블 생성 및 연결하기 | 93 | 2018/06/24 |
86 | [기타] G Suite - | 0 | 2018/07/26 |
85 | [리눅스서버] ./configure : /bin/sh^M : bad interpreter [duplicate] | 145 | 2018/07/29 |
84 | [리눅스서버] [쉘스크립트] 새로운 데이터베이스 테이블 생성 및 유저 연결 쉘스크립트 | 568 | 2018/07/29 |