PostgreSQL:选择时间戳为空的地方

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4476172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:45:58  来源:igfitidea点击:

PostgreSQL: Select where timestamp is empty

postgresql

提问by ReK_

I have a query that looks like the following:

我有一个如下所示的查询:

SELECT * FROM table WHERE timestamp = NULL;

SELECT * FROM table WHERE timestamp = NULL;

The timestamp column is a timestamp with time zone data type (second type in thistable). This is in PostgreSQL 8.4.

时间戳列是具有时区数据类型(表中的第二种类型)的时间戳。这是在 PostgreSQL 8.4 中。

What I'm trying to accomplish is to only select rows that have not had a timestamp inserted. When I look at the data in pgAdmin the field is empty and shows no value. I've tried where timestamp = NULL, 'EPOCH'(which you would think would be the default value), a valid timestamp of zeros (0000-00-00 00:00:00-00, which results in a out of range error), the lowest date possible according to the docs (January 1, 4713 BC) and a blank string ('', which just gets a data type mismatch error). There also appears to be no is_timestamp()function that I can use to check if the result is not a valid timestamp.

我想要完成的是只选择没有插入时间戳的行。当我查看 pgAdmin 中的数据时,该字段为空且不显示任何值。我试过 where timestamp = NULL, 'EPOCH'(你会认为这是默认值),一个有效的零时间戳(0000-00-00 00:00:00-00,这会导致超出范围的错误),根据文档可能的最低日期(January 1, 4713 BC)和一个空白string ( '',它只是得到一个数据类型不匹配错误)。似乎也没有is_timestamp()可用于检查结果是否为有效时间戳的函数。

So, the question is, what value is in that empty field that I can check for?

所以,问题是,我可以检查的空字段中的值是什么?

Thanks.

谢谢。

EDIT: The field does not have a default value.

编辑:该字段没有默认值。

回答by XMen

Try timestamp is nullas i use this syntax in MySQL

尝试timestamp is null在 MySQL 中使用此语法