I have recently had to change a database from one schema to another. Unfortunately, I have also had to change the prefix to bring some order in the tables in that specific destination schema.
In order to add a prefix to a set of tables within an existing schema, you will need to perform a few simply MySQL operations calling the ALTER and RENAME functions
In your MySQL editor (MySQL GUI Admin Tools, Workbench or PhpMyAdmin), type the following in the SQL script window:
Change urprefix and urDBName in the code below
SET group_concat_max_len=100000;
SELECT GROUP_CONCAT(CONCAT("ALTER TABLE ", table_name, " RENAME TO urprefix_", table_name) SEPARATOR ";")
FROM information_schema.tables
WHERE table_schema = "urDBName";
Bookmark/Search this post with