Modify the type and length of fields in MySQL

Source: Internet
Author: User

The commands for MySQL to modify field types are:

  Mysql> ALTER TABLE name modify column field name type;

Suppose that there is a table in MySQL: Address, which has a field in the initial case of varchar (30), then the modified type char can be entered in the MySQL console:

  ALTER TABLE address modify column City char (30);

Note the modification type should be cautious, because data between types needs to be converted, which can result in data errors or missing

If you want to extend the varchar (30) length, you can use:

  ALTER TABLE address modify column city varchar (60);

The same type of data field increases the length is not a problem, is often used, but the reduction of length may result in data loss

Modify the type and length of fields in MySQL

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.