A novel method for modifying the database name in MySQL.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.