授予数据库级别的权限 [英] Grant permission in database level
本文介绍了授予数据库级别的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
我正在使用SQL Server 2014.
我已经写了2个代码用于授予许可。
请参阅代码如下。
它们之间有什么区别?
问候。
我尝试过:
1)
使用testDB
go
授予改为用户名
2)
使用testDB
go
将database :: testDB上的alter赋予用户名
解决方案
在第二个语句中,您明确定义了您为其授予权限的类(数据库)。考虑一个示例,其中您在名为Test的数据库中具有名为Test的对象。如果没有定义类,可能不清楚你要授予哪个类权限。
通过查看无效GRANT语句的错误消息,可能最容易理解
以下声明
GRANT ALTER ON NotExisting TO SomeOne
会产生
消息15151,等级16,状态1,行4
找不到对象'NotExisting' ,因为它不存在或你没有权限。
而
GRANT ALTER ON database :: NotExisting TO SomeOne
将输出
消息15151,等级16,状态1,第6行
可以找不到数据库'NotExisting',因为它不存在或你没有权限。
在你的第一个例子中你没有定义任何安全,因此默认情况下使用数据库。
两者都执行相同的操作
GRANT ALTER TO
USER 给予特定用户的所有对象的alter权限
GRANT ALTER ON
用于授予特定架构的权限,请参阅 GRANT架构权限(Transact-SQL) [ ^ ]
Hi all.
I'm using SQL Server 2014.
I've written 2 codes for grant permission.
Please see codes below.
what's difference between them?
regards.
What I have tried:
1)
use testDB
go
grant alter to username
2)
use testDB
go
grant alter on database::testDB to username
解决方案
In the second statement you explicitly define the class (database) for which you grant privileges. Consider an example where you have and object called Test in a database named Test. Without defining the class it could be unclear for which class you are about to give permissions.
It's perhaps easiest to understand by looking at the error messages for invalid GRANT statement
The following statement
GRANT ALTER ON NotExisting TO SomeOne
would produce
Msg 15151, Level 16, State 1, Line 4 Cannot find the object 'NotExisting', because it does not exist or you do not have permission.
while
GRANT ALTER ON database::NotExisting TO SomeOne
would output
Msg 15151, Level 16, State 1, Line 6 Cannot find the database 'NotExisting', because it does not exist or you do not have permission.
In your first example you don't define any securable so database is used by default.
Both does the same operation
GRANT ALTER TO
USER is giving alter permission on all objects to the particular user
GRANT ALTER ON
used to give permission on particular schema , refer GRANT Schema Permissions (Transact-SQL)[^]
这篇关于授予数据库级别的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文