Mysql command line Deletes a field in the table _mysql

Source: Internet
Author: User
Tags mysql command line

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

Mysql> select * from test;
+------+--------+----------------------------------+------------+------------+------------+------------+
| t_id | T_name | T_password | T_birth | Birth | Birth1 | Birth2 |
+------+--------+----------------------------------+------------+------------+------------+------------+
| 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)

Executes the delete command, using the DROP keyword.
The basic syntax is: ALTER TABLE < table name > drop column < field name >;

The specific orders are as follows:

Mysql>ALTER TABLE test drop column Birth1;
Query OK, 0 rows affected (0.13 sec)
records:0 duplicates:0 warnings:0

Look at the results of the deletion, is not there is no birth1 field?

Mysql> select * from test;
+------+--------+----------------------------------+------------+------------+------------+
| t_id | T_name | T_password | T_birth | Birth | Birth2 |
+------+--------+----------------------------------+------------+------------+------------+
| 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)

On the MySQL based on the birthday of the age of the SQL statement Date function, this article on the introduction of so many, I hope to 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.