是否可以不使用模式名调用用户定义的函数?

时间:2021-01-17 12:55:34

I'm using MS SQL 2005 and when I create a function I need to put the schema name to call it:

我使用的是MS SQL 2005,当我创建一个函数时,我需要使用模式名来调用它:

select dbo.MyFunc

All my tables are also in "dbo" schema and I don't need the schema name to reference it, so I'd like to know if I'm missing some configuration that could do the same to functions.

我所有的表都在“dbo”模式中,我不需要使用模式名来引用它,所以我想知道我是否遗漏了一些可以对函数执行同样操作的配置。

3 个解决方案

#1


14  

Short answer, no it isn't.

简短的回答,不,不是。

You should consider to prefix all your database objects with the schema owner to avoid having sql server to "look it up".

您应该考虑使用模式所有者对所有数据库对象进行前缀,以避免sql服务器“查找它”。

It makes your statements more readable and gives a slight increase in performance (although you'd probably won't notice it).

它使语句更具可读性,并略微提高了性能(尽管您可能不会注意到)。

Regards, Lieven

问候,列文

#2


8  

Unlike all the other database objects (tables, views and stored procedures), user defined functions always need the schema name when they are referenced. It's a quirk of SQL Server.

与所有其他数据库对象(表、视图和存储过程)不同,用户定义的函数在被引用时总是需要模式名。这是SQL Server的一个怪癖。

#3


6  

*Scalar-valued functions must be invoked by using at least the two-part name of the function

*必须至少使用函数的两部分名称来调用标量值函数

http://msdn.microsoft.com/en-us/library/ms186755.aspx

http://msdn.microsoft.com/en-us/library/ms186755.aspx

+1 Parent

+ 1父母

Borik

Borik

#1


14  

Short answer, no it isn't.

简短的回答,不,不是。

You should consider to prefix all your database objects with the schema owner to avoid having sql server to "look it up".

您应该考虑使用模式所有者对所有数据库对象进行前缀,以避免sql服务器“查找它”。

It makes your statements more readable and gives a slight increase in performance (although you'd probably won't notice it).

它使语句更具可读性,并略微提高了性能(尽管您可能不会注意到)。

Regards, Lieven

问候,列文

#2


8  

Unlike all the other database objects (tables, views and stored procedures), user defined functions always need the schema name when they are referenced. It's a quirk of SQL Server.

与所有其他数据库对象(表、视图和存储过程)不同,用户定义的函数在被引用时总是需要模式名。这是SQL Server的一个怪癖。

#3


6  

*Scalar-valued functions must be invoked by using at least the two-part name of the function

*必须至少使用函数的两部分名称来调用标量值函数

http://msdn.microsoft.com/en-us/library/ms186755.aspx

http://msdn.microsoft.com/en-us/library/ms186755.aspx

+1 Parent

+ 1父母

Borik

Borik