MySQL's alter statement usage summary

Source: Internet
Author: User

1: Delete Columns

ALTER table "table name" DROP "column name"

2: Add columns

ALTER table "table name" ADD "column name" INT not NULL COMMENT ' comment description '

3: Modify the column type information

ALTER table "table name" Change "column Name" "New column name (you can use the same name as the original column)" BIGINT not NULL COMMENT ' comment description '

4: Renaming columns

ALTER table "table name" Change "column Name" "New column name" BIGINT not NULL COMMENT ' comment description '

5: Renaming a table

ALTER table "table name" RENAME "Table new name"

6: Delete primary key in table

Alter table "Tables name" Drop PRIMARY key

7: Add primary key

ALTER TABLE sj_resource_charges ADD CONSTRAINT pk_sj_resource_charges PRIMARY KEY (resid,resfromid)

8: Add index

ALTER TABLE sj_resource_charges Add index index_name (NAME);

9: Add a unique limit condition index

ALTER TABLE sj_resource_charges Add unique emp_name2 (cardnumber);

10: Delete Index

ALTER TABLE tablename DROP INDEX emp_name;

MySQL's alter statement usage summary

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.