MySQL basic syntax

Source: Internet
Author: User


Add a column to a column name
ALTER TABLE table_name ADD column_name int after column_name;

Change Column Name
ALTER TABLE table_name change old_column_name new_column_name int;

Modify Type
ALTER TABLE table_name MODIFY COLUMN_NAME float;

Delete Column
ALTER TABLE table_name DROP COLUMN_NAME;

Modify Table Name
ALTER TABLE old_table_name rename new_table;

Deletion of table structure
DROP TABLE table_name (case of unexpected key) with CHECK option


Add primary Key
ALTER TABLE TABLE_NAME ADD PRIMARY key (COLUMN1,COLUMN2);

Delete primary key
ALTER TABLE table_name drop PRIMARY key;

Add constraint
ALTER TABLE table_name add unique (column_name);

Delete Constraint
ALTER TABLE table_name DROP INDEX column_name;

MySQL basic syntax

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.