MySQL command line deletes a field in the table, mysql Command Line Field

Source: Internet
Author: User
Tags mysql command line

MySQL command line deletes a field in the table, mysql Command Line Field

Let's take a look at the table structure before deletion:

Mysql> select * from test;
+ ------ + -------- + -------------------------------- + ------------ + -------------- + ------------ +
| T_id | t_name | t_password | t_birth | birth | birth1 | bir22. |
+ ------ + -------- + -------------------------------- + ------------ + -------------- + ------------ +
| 1 | name1 | 12345678901234567890123456789012 | NULL | 1990-01-01 | 0000-00-00 | 2013-01-01 |
| 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 | NULL | 0000-00-00 | 2013-01-01 |
+ ------ + -------- + -------------------------------- + ------------ + -------------- + ------------ +
2 rows in set (0.00 sec)

Run the DELETE command and use the drop keyword.
The basic syntax is: alter table <table Name> drop column <field Name>;

The specific command is as follows:

Mysql> alter table test drop column birth1;
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0

Check the deleted result. Is there no birth1 field?

Mysql> select * from test;
+ ------ + -------- + ---------------------------------- + ------------ +
| T_id | t_name | t_password | t_birth | birth | bir22. |
+ ------ + -------- + ---------------------------------- + ------------ +
| 1 | name1 | 12345678901234567890123456789012 | NULL | 1990-01-01 | 2013-01-01 |
| 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 | NULL | 2013-01-01 |
+ ------ + -------- + ---------------------------------- + ------------ +
2 rows in set (0.00 sec)

This article describes the date functions of SQL statements used to calculate the age based on the birthday in MySQL. I hope this will help you. Thank you!

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.