SQL中的双冒号(::)符号 [英] Double colon (::) notation in SQL

查看:7467
本文介绍了SQL中的双冒号(::)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

取得某人的代码,这是一个where子句的一部分,任何人都知道双冒号表示什么?

  b.date_completed> a.dc :: date + INTERVAL'1 DAY 7:20:00'


解决方案

它根据RDBMS而变化,但如果我猜是的,这是PostgreSQL,在这种情况下 :: 转换 a.dc



日期类型 p>

在MS SQL Server 2000中:


对于内置的用户定义函数
返回一个表,函数名
必须指定一个前导
双冒号(::)以区分
和用户定义的函数
不内置。它也必须是
指定为单一部件名称,没有
数据库或所有者资格。对于
示例:SELECT * FROM
:: fn_helpcollat​​ions()b ..对于返回
标量值的内置
用户定义函数,函数名称必须为
指定为单一部件名称(do
不指定数据库或所有者)。不要
指定前导双冒号(::)。


在MS SQL Server 2005中:


不再需要双冒号
用于返回表的UDF。


但是...


SQL
Server 2005中需要双冒号
在架构,证书,端点,
和一些其他的安全证书。



使用用户定义类型时,类型的静态
方法必须使用双冒号调用
语法。


资料来源: BOL Kalen Delaney的博客


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'

解决方案

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.

In other flavors...

In MS SQL Server 2000:

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 (::).

In MS SQL Server 2005:

Double-colons are no longer required for UDFs that return a table.

However...

Double-colons are required in SQL Server 2005 when granting permissions on schemas, certificates, endpoints, and a few other securables.

As well as...

When using User-Defined Types, static methods of the type must be called using the double-colon syntax.

Sources: BOL and Kalen Delaney's Blog

这篇关于SQL中的双冒号(::)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆