MySQL Study notes Day sixth

Source: Internet
Author: User

Change the structure of the data table:
ALTER TABLE Tb_name Action,[action,action] (before using ALTER TABLE, you need to see the current definition of the data table and need to execute the show CREATE TABLE statement)
ALTER TABLE Tb_name modify columns+ data type
ALTER TABLE Tb_name change column_name column_new_name+ data type
Change changes the table name and data type, MODFY can only change the data type
You can also change the character set: ALTER TABLE tb_name modify T char () Character Set USC2
For data columns, when two data columns have the same data column, the comparison is much faster

Char (a more slow comparison of the char (

Change the storage Engine:
ALTER TABLE table_name ENGINE=ENGINE_NAME if the data column includes a BLOB data column, it cannot be converted to a memory engine,
Because the memory engine does not support blobs,
When InnoDB defines an external check constraint, the foreign key is lost when the storage engine is converted, and only InnoDB supports the foreign key

Renaming a data table
(1) ALTER TABLE Tb1_name Rename to New_tb1_name
(2) Rename table Tb1_name to New_tb1_name
ALTER TABLE can only modify one data table at a time, but rename ... to can be modified together by multiple: rename table T1 to t2,t2 to T3,...
If you add a database prefix to the renaming, you can migrate the data table from one database to another database.
      

Alter Table  to  Table to B.tb1_name

MySQL Study notes Day sixth

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.