A novel method for modifying the database name in MySQL.
MySQL introduced a rename database operation in MySQL 5.1, but does not support this command after MySQL5.1.23. It can be said that it is an experimental function, not supported in production (mysql-5.1 release in mysql-5.1.30), so in production we sometimes need to change the library name to the pursuit of perfection. How can this problem be solved?
Here is a work und.
1. Create a new database name:
Copy codeThe Code is as follows:
Mysql> create database db_v2;
2. Generate the rename statement, Migrate from olddb. Here I will use sbtest in olddb;
Copy codeThe Code is as follows: mysql> select concat ("rename table", table_schema ,". ", table_name," to db_v2. ", table_name,"; ") into outfile '/tmp/rename_to_db_v2. SQL' from information_schema.tables where table_schema = 'sbtest ';
3. Execute the generated SQL
Copy codeThe Code is as follows: mysql> source/tmp/rename_to_db_v2. SQL
That's easy.
Good luck!
Change MYSQL Data Table Name
It is impossible to implement a query statement.
One statement is
Rename table tb_name TO new_name;
I teach you a trick.
Use the program to output a set of statements and execute them in mysql.
Example: php
I would like to write the program code to you, do not know your mysql DATA STRUCTURE, 154651166 park412@hotmail.com
You add me
If you are interested, you can solve it for you.
How can I change the field name in the MySQL database?
Alter table student change physics physisc char (10) not null;
Char (10) not null is the create_definition of your physisc field.