首页 > 解决方案 > 您可以将空值插入 SQL 中的日期数据类型(如果可以,如何插入)?

问题描述

我一直在为学校项目开发我的 SQL 数据库,但我的想法有问题。我正在做一个汽车服务数据库(全部组成),并且我有一个表的数据类型列(deadline我的语言中的名称 - 'rok' 和 'narocilo'),我试图将 null 插入到其中的某些行中客户未指定截止日期。 dateorder

create table narocilo
(
    id_narocila integer NOT null,
    opis varchar(50),
    cena integer,
    status varchar(20),
    datum_narocila date,
    rok date
);

这是我尝试插入 null 的一些方法,但它们都不起作用

所以,我的问题是,我可以在列中插入 nulldate吗?如果可以,如何?

先感谢您!

标签: sqloracledatenull

解决方案


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

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

推荐阅读