Add and delete column fields dynamically in MySQL

Source: Internet
Author: User
Okay, I admit it was a major mistake in my project. During the trial run of this project, I modified the length and value of the database field twice, in order not to affect the existing data, I can only find another way to dynamically add, delete, modify, and add column fields? 1 altertableTableNamedropcolumnfield

Okay, I admit it was a major mistake in my project. During the trial run of this project, I modified the length and value of the database field twice, in order not to affect the existing data, I can only find another way to dynamically add, delete, modify, and add column fields? 1 alter table TableName drop column field

Okay, I admit it was a major mistake in my project. During the trial run of this project, I modified the length and value of the database field twice, in order not to affect the existing data, I can only find another way to dynamically add, delete, and modify columns.

Dynamically add column Fields

?

1

Alter table TableName drop column field_id;

Dynamically delete column Fields

?

1

Alert TABLE table_name change old_field_name new_field_name field_type;

Dynamic Modification of column Fields

?

1

Alert TABLE table_name change old_field_name new_field_name field_type;

Errors and what I want to say, I have written them in this blog (MySQL dynamically modifies the varchar length). You can also see that, in fact, we do not advocate this approach.

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.