Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
能否在SQL中的日期数据类型中插入空值(如果是,如何插入)?_Sql_Oracle_Date_Null - Fatal编程技术网

能否在SQL中的日期数据类型中插入空值(如果是,如何插入)?

能否在SQL中的日期数据类型中插入空值(如果是,如何插入)?,sql,oracle,date,null,Sql,Oracle,Date,Null,我一直在为学校项目开发SQL数据库,我的想法有问题。我正在做一个汽车服务数据库(全部由用户创建),我有一个数据类型为date的列deadline,用于表order(在我的语言中都有名称-'rok'和'narocilo'),我试图在客户未指定截止日期的行中插入null create table narocilo ( id_narocila integer NOT null, opis varchar(50), cena integer, status varchar

我一直在为学校项目开发SQL数据库,我的想法有问题。我正在做一个汽车服务数据库(全部由用户创建),我有一个数据类型为
date
的列
deadline
,用于表
order
(在我的语言中都有名称-'rok'和'narocilo'),我试图在客户未指定截止日期的行中插入null

create table narocilo
(
    id_narocila integer NOT null,
    opis varchar(50),
    cena integer,
    status varchar(20),
    datum_narocila date,
    rok date
);
这是我尝试插入null的一些方法,但它们都不起作用

  • 截止日期('dd-mm-yyyy',空)
  • 截止日期(空)
  • null
  • 截止日期('null')
所以,我的问题是,我可以在
日期
列中插入null吗?如果可以,如何插入


提前谢谢你

您必须插入整行的数据,但只要您没有像上面那样将该字段定义为非空,就可以在日期字段中插入空值:

INSERT INTO narocilo(id_narocila, opis, cena, status, datm_narocila, rok)
VALUES (1001, 'something', 6, 'Open', NULL, NULL)

insert
NULL
的一个非常简单的方法是将它们一起从
insert
中删除:

INSERT INTO narocilo (id_narocila, opis, cena, status)
    VALUES (?, ?, ?, ?);

从技术上讲,这将插入默认值。但是您没有指定一个,因此默认值是
NULL

NULL
本身应该可以工作。
NULL
已经是默认值,如果您不提供
非NULL
值,它会隐式插入
NULL
。e、 g.
插入narocilo值(111)
数据插入一个
null
。\u narocila
适用于我()。请显示您的
INSERT
语句以及您遇到的具体问题,例如错误消息。