SQL 中的双冒号 (::) 表示法 [英] Double colon (::) notation in SQL
问题描述
拿起某人的代码,这是 where 子句的一部分,有人知道双冒号表示什么吗?
Have picked up someone's code and this is a part of a where clause, anyone know what the double colon indicates?
b.date_completed > a.dc::date + INTERVAL '1 DAY 7:20:00'
推荐答案
它因 RDBMS 而异,但如果我猜对了,那就是 PostgreSQL,在这种情况下 ::
转换 a.dc
到 date
的日期类型.
It varies based on RDBMS, but if I guess right, that's PostgreSQL, in which case the ::
converts a.dc
to a date type of date
.
其他口味...
在 MS SQL Server 2000 中:
In MS SQL Server 2000:
对于内置的用户定义函数返回一个表,函数名必须用前导指定双冒号 (::) 来区分从用户定义的函数是不是内置的.它也必须是指定为单部分名称,没有数据库或所有者资格.为了示例:SELECT * FROM::fn_helpcollations() b.. 对于内置返回一个用户定义的函数标量值,函数名必须被指定为一个组成部分的名称(做不指定数据库或所有者).不要指定前导双冒号 (::).
For built-in user-defined functions that return a table, the function name must be specified with a leading double colon (::) to distinguish it from user-defined functions that are not built-in. It also must be specified as a one-part name with no database or owner qualifications. For example: SELECT * FROM ::fn_helpcollations() b.. For built-in user-defined functions that return a scalar value, the function name must be specified as a one-part name (do not specify database or owner). Do not specify a leading double colon (::).
在 MS SQL Server 2005 中:
In MS SQL Server 2005:
不再需要双冒号对于返回表的 UDF.
Double-colons are no longer required for UDFs that return a table.
不过……
SQL 中需要双冒号Server 2005 时授予权限在架构、证书、端点上,以及其他一些安全资产.
Double-colons are required in SQL Server 2005 when granting permissions on schemas, certificates, endpoints, and a few other securables.
还有...
当使用用户定义类型时,静态必须调用该类型的方法使用双冒号语法.
When using User-Defined Types, static methods of the type must be called using the double-colon syntax.
来源:BOL 和 Kalen Delaney 的博客
这篇关于SQL 中的双冒号 (::) 表示法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!