题目情况

数据库版本情况
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 12.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
postgres=#
数据库操作
ostgres=# select now() + interval'2 days';
?column?
-------------------------------
2022-12-29 11:30:45.691244+08
(1 row)
postgres=# select now()+2;
2022-12-27 11:30:54.595 CST [1798] ERROR: operator does not exist: timestamp with time zone + integer at character 13
2022-12-27 11:30:54.595 CST [1798] HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
2022-12-27 11:30:54.595 CST [1798] STATEMENT: select now()+2;
ERROR: operator does not exist: timestamp with time zone + integer
LINE 1: select now()+2;
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=#
postgres=# select current_date+interval'2 days';
?column?
---------------------
2022-12-29 00:00:00
(1 row)
postgres=# select current_date+2;
?column?
------------
2022-12-29
(1 row)
postgres=#
疑问,第二个选项
postgres=# select now() + 2;
2022-12-27 11:36:49.449 CST [1798] ERROR: operator does not exist: timestamp with time zone + integer at character 14
2022-12-27 11:36:49.449 CST [1798] HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
2022-12-27 11:36:49.449 CST [1798] STATEMENT: select now() + 2;
ERROR: operator does not exist: timestamp with time zone + integer
LINE 1: select now() + 2;
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=#


最后修改时间:2024-02-02 13:02:18
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




