MySQL modifies column names and column types

Source: Internet
Author: User

Modifying the data type of a column name or column in MySQL(2012-04-03 08:59:25) reproduced
Tags: mysql modify column name modify column data type it Category: Databases

Refer to the syntax in the links below

Http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

Methods to modify only the data type of a column:

Can usually be written as ALTER TABLE name modify column column name new type

For example: The type of column sname in the student table is char (20), which is now modified to varchar, the SQL statement is as follows

ALTER TABLE student Modify column sname varchar (20);

Methods for modifying the data types of column names and columns at the same time:

Can usually be written as ALTER TABLE name change column old column name new column type

For example: The type of column sname in the student table is char (20), which is now modified to stuname varchar, the SQL statement is as follows

ALTER TABLE student Change column sname stuname varchar (20);

MySQL modifies column names and column types

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.