简体   繁体   English

CURRENT_TIMESTAMP 是 ANSI SQL 中的函数吗?

[英]Is CURRENT_TIMESTAMP a function in ANSI SQL?

I was using the bigquery function current_timestamp() when i discovered that you can use it without parenthesis if you want.我在使用 bigquery 函数current_timestamp()时发现如果需要,您可以不带括号使用它。 Since it is a function, i would advocate for parenthesis, but what i find on the internet indicates that you can indeed use it without in different standards.由于它是一个函数,我会提倡使用括号,但我在互联网上发现的内容表明您确实可以在没有不同标准的情况下使用它。

I found that in ANSI SQL 1992 it is indeed a function ( based on this answer ).我发现在 ANSI SQL 1992 中它确实是一个函数( 基于这个答案)。 Yet i did not find why it is allowed to call it without parenthesis and even if the standard advocates for parenthesis or not ?然而,我没有发现为什么允许不带括号地调用它,即使标准提倡不带括号? Snowflake is saying that it allows for a call without parenthesis to comply with ANSI SQL... 雪花说它允许不带括号的调用符合 ANSI SQL ......

So does anyone knows what it is ?那么有人知道它是什么吗?

Many thanks in advance !提前谢谢了 !

Based on 2.1.2.70 F411 :基于2.1.2.70 F411

 <current timestamp value function> ::= CURRENT_TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]

It is a function and (<precision>) is optional so the following are correct:它是一个函数并且(<precision>)是可选的,因此以下是正确的:

SELECT CURRENT_TIMESTAMP;

SELECT CURRENT_TIMESTAMP(3);

Based on that definition SELECT CURRENT_TIMESTAMP() shouldn't work but often is implemented.基于该定义SELECT CURRENT_TIMESTAMP()不应该工作,但经常被实现。

db<>fiddle demo - MySQL vs db<>fiddle demo - PostgreSQL db<>fiddle 演示 - MySQLdb<>fiddle 演示 - PostgreSQL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM