在 SQL Server 2008 上运行“ALTER DATABASE SET SINGLE_USER”语句所需的权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9798968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permissions required to run 'ALTER DATABASE SET SINGLE_USER' statement on SQL Server 2008
提问by Oleg Sakharov
I've came across the case when the following statement throws an error saying it can't be executed because of the permission:
我遇到过以下情况,以下语句抛出错误,表示由于权限而无法执行:
ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Couldn't find anywhere on the web any information about the permissions it needs.
无法在网络上的任何地方找到有关所需权限的任何信息。
回答by Remus Rusanu
Requires ALTER permission on the database.
需要对数据库的 ALTER 权限。
Some specific SET
permissions are listed in ALTER DATABASE SET options
:
一些特定的SET
权限列在ALTER DATABASE SET options
:
EMERGENCY
:ALTER DATABASE
permission for the subject database is required to change a database to the offline or emergency state. The server levelALTER ANY DATABASE
permission is required to move a database from offline to online.- DB_CHAINING: To set this option, requires
CONTROL SERVER
permission on the database.- TRUSTWORTHY: To set this option, requires
CONTROL SERVER
permission on the database.
EMERGENCY
:ALTER DATABASE
将数据库更改为离线或紧急状态需要主题数据库的权限。将ALTER ANY DATABASE
数据库从离线移动到在线需要服务器级别的权限。- DB_CHAINING:要设置此选项,需要
CONTROL SERVER
对数据库的权限。- 值得信赖:要设置此选项,需要
CONTROL SERVER
对数据库的权限。
回答by Andrey Gurinov
Try this from admin account:
从管理员帐户试试这个:
USE [YOUR_DB]
GO
GRANT ALTER TO your_user
GO
But mind that the login must have a user in the specified DB.
但请注意,登录必须在指定的数据库中有一个用户。
Or, if you want to grant this permission on every database on the server, then you can grant the permission on the server level to the login:
或者,如果您想对服务器上的每个数据库授予此权限,则可以将服务器级别的权限授予登录:
USE master
GO
GRANT ALTER ANY DATABASE TO your_login
GO