《Mysql必讀MySQL命令行刪除表中的一個字段》要點:
本文介紹了Mysql必讀MySQL命令行刪除表中的一個字段,希望對您有用。如果有疑問,可以聯系我們。
MYSQL必讀先看看刪除之前的表結構:
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)
執行刪除命令,使用drop關鍵字.
基本的語法為:alter table <表名> drop column <字段名>;
具體的命令如下:
mysql> alter table test drop column birth1;
Query OK, 0 rows affected (0.13 sec)
Records: 0? Duplicates: 0? Warnings: 0
看看刪除后的結果,是不是已經沒有birth1字段了?
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)
關于MySQL中根據生日計算年齡的SQL語句日期函數,本文就介紹這么多,希望對大家有所幫助,謝謝!
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/1617.html