mysql-modifying field types and modifying field names

Source: Internet
Author: User

article turned from: 79354136

MySQL Modify field type:--can modify field type, type length, default value, comment--make a change to a fieldALTER TABLETable name MODIFYCOLUMNField name new data type new type length new default value new comment;--column can be omittedAlter TableTable1 ModifycolumnColumn1decimal(Ten,1)DEFAULT NULLCOMMENT'Notes';--Normal, can modify field type, type length, default value, commentmysql Modify field name:ALTER TABLETable name change old field name new data type new field name; Alter TableTable1 Change Column1 Column1varchar( -)DEFAULT 1.2COMMENT'Notes';--Normal, the field name does not change, you can modify the field type, type length, default value, commentAlter TableTable1 Change Column1 Column2decimal(Ten,1)DEFAULT NULLCOMMENT'Notes' --Normal, can modify field name, field type, type length, default value, commentAlter TableTable1 Change Column2 column1decimal(Ten,1)DEFAULT NULLCOMMENT'Notes' --Normal, can modify field name, field type, type length, default value, commentAlter TableTable1 change Column1 column2;--Error

Change Note:
The field type after the field must be added, regardless of whether the field type or field name is modified, the default value is null if not passed by default

mysql-modifying field types and modifying field names

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.