在日期字段中插入空值的兼容性查询 [英] Compatibility Query for inserting null values in datefield
问题描述
我在我们的项目中使用Oracle和MySQL数据库.因此,我们正在尝试为两个数据库编写通用查询.
I'm using Oracle and MySQL database in our project. So we are trying to write common queries for both databases.
我正在尝试在两个数据库表的日期字段中插入一个日期.两个数据库仅支持以下日期格式:2013-07-19
.在DML操作过程中,将日期插入为空或空时会遇到问题.
I'm trying to insert a date in a date field into both database tables. Both databases support this date format only: 2013-07-19
. In the course of our DML operations we are facing a problem when inserting dates as Empty or Null.
两个数据库都有自己的语法,用于在日期"字段/列中存储空字段".
Both databases have their own syntax to store an "empty field" in a Date field/column.
MySQL允许日期为0000-00-00
或NULL
(具体写在适当的位置).但是Oracle不支持这种格式. Oracle仅允许日期字段为Empty
.
MySQL allows dates as 0000-00-00
or NULL
(specifically written at an appropriate position). But Oracle does not support this format. Oracle only allows date fields as Empty
.
在这种情况下如何编写常见查询?
How to write common queries in this type of situation?
推荐答案
INSERT INTO TABLENAME(DATEFIELD) VALUES(NULL);
...在 MySQL 和
...works both in MySQL and Oracle, so you could use that.
这篇关于在日期字段中插入空值的兼容性查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!