MySQL adds a field deletion field, modifies the field name, and modifies the field type.

Source: Internet
Author: User

The simple Syntax of MySQL is commonly used, but it is not easy to remember. Of course, these SQL syntaxes are basically common in various databases. Listed below:

1. Add a field

Alter table user add column new1 varchar (20) default null; // Add a field, empty by default
Alter table user add column new2 varchar (20) not null; // Add a field, which cannot be blank by default.

2. delete a field
Alter table user drop column new2; // delete a field

3. modify a field
Alter table user modify new1 varchar (10); // modify the type of a field
Alter table user change new1 new4 int; // modify the name of a field. You must specify the field type again.

Author'sArticleAll original, spend a lot of energy and time, here I beg you can take care of my shop: http://wamogu.taobao.com. Adding a page view is the greatest comfort to the work of the author. Thank you for taking the mouse off.

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.