sql - 您可以将空值插入 SQL 中的日期数据类型(如果可以,如何插入)?
问题描述
我一直在为学校项目开发我的 SQL 数据库,但我的想法有问题。我正在做一个汽车服务数据库(全部组成),并且我有一个表的数据类型列(deadline
我的语言中的名称 - 'rok' 和 'narocilo'),我试图将 null 插入到其中的某些行中客户未指定截止日期。 date
order
create table narocilo
(
id_narocila integer NOT null,
opis varchar(50),
cena integer,
status varchar(20),
datum_narocila date,
rok date
);
这是我尝试插入 null 的一些方法,但它们都不起作用
to_date('dd-mm-yyyy', null)
to_date(null)
null
to_date('null')
所以,我的问题是,我可以在列中插入 nulldate
吗?如果可以,如何?
先感谢您!
解决方案
您必须插入一整行的数据,但只要您没有像上面那样将该字段定义为 NOT NULL,就可以将 NULL 值插入日期字段:
INSERT INTO narocilo(id_narocila, opis, cena, status, datm_narocila, rok)
VALUES (1001, 'something', 6, 'Open', NULL, NULL)
推荐阅读
- swift - Swift Alamofire 使用 UIWebView 向 VC 请求回答
- google-maps - 在 iOS 上关闭信息窗口
- css - SCSS - 将代码与参数组合/缩短/简化?
- ffmpeg - ffmpeg不正确的屁股字幕边框宽度
- python-3.x - ImportError: DLL load failed: The specified module could not be found IOT Simulate
- java - Spring Service - 我应该传递实体 ID 还是实体本身?
- r - 有没有办法编写一个随机采样数据帧中连续行的单行命令?
- c++ - 程序运行两次后关闭
- vue.js - 如何以编程方式基于变量添加事件?
- turbo-c++ - 我正在尝试使用 System() 函数在 C 程序中打开记事本文件,我的代码在 Dev C++ 中工作,但在 turbo 中不工作