Ways to add fields and modify fields in MySQL

Source: Internet
Author: User

MySQL adds fields to the method is not complicated, the following will give you a detailed description of the MySQL add fields and modify the fields and other operations to implement the method, I hope you learn to add fields in MySQL will be helpful.


1. Log in to the database

>mysql-u root-p Database name


2. Querying all data Sheets

>show tables;


3. Querying the table for field information

>DESC table name;


4.1 Adding a table field


ALTER TABLE table1 add transactor varchar (ten) not Null;


ALTER TABLE table1 add ID int unsigned not Null auto_increment primary key


4.2. Modify the field type of a table and specify null or non-empty

>alter Table name change field Name field Name field type [whether non-null allowed];

>alter Table name Modify field Name field type [allow non-null];


>alter Table name Modify field Name field type [allow non-null];


4.3. Modify the field name of a table and specify null or non-empty

>alter Table name change field original Name field new Name field type [whether non-null is allowed


4.4 If you want to delete a field, you can use the command: ALTER TABLE mytable DROP field name;


This article is from the "My Ops Time" blog, so be sure to keep this source http://aaronsa.blog.51cto.com/5157083/1746865

Ways to add fields and modify fields in MySQL

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.