MySQL basic syntax-the operation of the table

Source: Internet
Author: User

1. Create a table

Basic syntax

Create Table tableName (        field1 datatype,        field2 datatype,        field3 datatype  );
View CodeField: Queue name datatype: column type

Create a student table example:

Create Table Student (      int,      varchar()       Char (6));
View Code

2. Modify the table

2.1 Adding columns to a table

Basic syntax

Alter Table tableName         Add (column datatype);

Add Student table One column sorce, type int

Alter Table Student          Add int);
View Code

2.2 Modifying a table's columns

Basic syntax

Alter Table tableName        Modify (column datatype);//commonly used to modify data types

Change the name length of the student table to 60

Alter Table Student         varchar ());
View Code

2.3 Deleting a table's columns

Basic syntax

Alter Table tableName         Drop (column);

Delete Student's Sorce

Alter Table Student         drop Sorce;
View Code

3. Other syntax

Modify the name of the table:

 to Newtablename;

To modify the character set of a table:

Alter Table character set UTF8;

MySQL basic syntax-the operation of the table

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.