valvur.blogg.se

Navicat premium key
Navicat premium key








Or SELECT GROUP_CONCAT('RENAME TABLE $1.', table_name, ' TO $2.', table_name SEPARATOR ' ') Take your pick, but I prefer the original): SELECT CONCAT('RENAME TABLE $1.', table_name, ' TO $2.', table_name, ' ') You can use either of these two scripts (I originally suggested the former and someone "improved" my answer to use GROUP_CONCAT. You must create the destination database before running the script generated from the command. You can use SQL to generate an SQL script to transfer each table in your source database to the destination database. If you have stored procedures, you can copy them afterwards: If that is the case, use a traditional way to clone a database and then drop the old one: If some table has a trigger, it cannot be moved to another database using above method (will result Trigger in wrong schema error). If your database has no password, remove the -u username -ppassword part.

navicat premium key

There is no space between the option -p and the password.OR for table in `mysql -u root -ppassword -s -N -e "use old_db show tables from old_db "` do mysql -u root -ppassword -s -N -e "use old_db rename table old_db.$table to new_db.$table " done You will need to adjust the permissions after that.įor scripting in a shell, you can use either of the following: mysql -u username -ppassword old_db -sNe 'show tables' | while read table \ĭo mysql -u username -ppassword -sNe "rename table old_db.$table to new_db.$table" done For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database: RENAME TABLE old_db.table TO new_db.table










Navicat premium key