亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

To make a date column null, use ALTER TABLE and MODIFY and set the date to NULL. Following is the syntax ?

alter table yourTableName modify column yourColumnName date NULL;

登錄后復(fù)制

首先讓我們創(chuàng)建一個(gè)表格。在這里,我們將列設(shè)置為NOT NULL −

mysql> create table DemoTable
(
   ShippingDate date NOT NULL
);
Query OK, 0 rows affected (0.78 sec)

登錄后復(fù)制

Now, insert NULL value in the above table. An error would generate since we have set the column to be NOT NULL −

mysql> insert into DemoTable values(null);
ERROR 1048 (23000) − Column 'ShippingDate' cannot be null

登錄后復(fù)制

Now, let us alter the table and allow NULL in the above table −

mysql> alter table DemoTable modify column ShippingDate date NULL;
Query OK, 0 rows affected (1.81 sec)
Records : 0 Duplicates : 0 Warnings : 0

登錄后復(fù)制

現(xiàn)在,再次嘗試使用插入命令將NULL插入到上述表中。由于我們已經(jīng)修改了表以接受NULL,所以不會(huì)生成錯(cuò)誤−

mysql> insert into DemoTable values(null);
Query OK, 1 row affected (1.21 sec

登錄后復(fù)制

Display all records from the table using select statement −

mysql> select *from DemoTable;

登錄后復(fù)制

這將產(chǎn)生以下輸出 −

+--------------+
| ShippingDate |
+--------------+
| NULL         |
+--------------+
1 row in set (0.00 sec)

登錄后復(fù)制

以上就是MySQL 查詢使日期列為 NULL?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!

分享到:
標(biāo)簽:MySQL null 列為 日期 查詢
用戶無頭像

網(wǎng)友整理

注冊時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評(píng)定2018-06-03

通用課目體育訓(xùn)練成績評(píng)定