DENY 資料庫權限 (Transact-SQL)
拒絕資料庫的權限。
語法
DENY <permission> [ ,...n ]
TO <database_principal> [ ,...n ] [ CASCADE ]
[ AS <database_principal> ]
<permission> ::=
permission | ALL [ PRIVILEGES ]
<database_principal> ::=
Database_user
| Database_role
| Application_role
| Database_user_mapped_to_Windows_User
| Database_user_mapped_to_Windows_Group
| Database_user_mapped_to_certificate
| Database_user_mapped_to_asymmetric_key
| Database_user_with_no_login
引數
permission
指定可以拒絕的資料庫權限。 如需權限清單,請參閱這個主題稍後的「備註」一節。ALL
這個選項不會拒絕所有可能的權限。 拒絕 ALL 相當於拒絕下列權限:BACKUP DATABASE、BACKUP LOG、CREATE DATABASE、CREATE DEFAULT、CREATE FUNCTION、CREATE PROCEDURE、CREATE RULE、CREATE TABLE 和 CREATE VIEW。PRIVILEGES
為符合 ISO 而包含這個項目。 不會變更 ALL 的行為。CASCADE
指出也會對指定主體對其授與權限的主體拒絕權限。AS <database_principal>
指定主體,執行這項查詢的主體會從這個主體衍生權限來拒絕權限。Database_user
指定資料庫使用者。Database_role
指定資料庫角色。Application_role
指定應用程式角色。Database_user_mapped_to_Windows_User
指定對應至 Windows 使用者的資料庫使用者。Database_user_mapped_to_Windows_Group
指定對應至 Windows 群組的資料庫使用者。Database_user_mapped_to_certificate
指定對應至憑證的資料庫使用者。Database_user_mapped_to_asymmetric_key
指定對應至非對稱金鑰的資料庫使用者。Database_user_with_no_login
指定不含對應伺服器層級主體的資料庫使用者。
備註
資料庫是一個安全性實體,它由伺服器所包含,該伺服器是權限階層中之該安全性實體的父系。 下表所列的是可以拒絕之最特定和最有限的資料庫權限,並列出利用隱含方式來併入這些權限的較通用權限。
資料庫權限 |
資料庫權限所隱含 |
伺服器權限所隱含 |
---|---|---|
ALTER |
CONTROL |
ALTER ANY DATABASE |
ALTER ANY APPLICATION ROLE |
ALTER |
CONTROL SERVER |
ALTER ANY ASSEMBLY |
ALTER |
CONTROL SERVER |
ALTER ANY ASYMMETRIC KEY |
ALTER |
CONTROL SERVER |
ALTER ANY CERTIFICATE |
ALTER |
CONTROL SERVER |
ALTER ANY CONTRACT |
ALTER |
CONTROL SERVER |
ALTER ANY DATABASE AUDIT |
ALTER |
ALTER ANY SERVER AUDIT |
ALTER ANY DATABASE DDL TRIGGER |
ALTER |
CONTROL SERVER |
ALTER ANY DATABASE EVENT NOTIFICATION |
ALTER |
ALTER ANY EVENT NOTIFICATION |
ALTER ANY DATASPACE |
ALTER |
CONTROL SERVER |
ALTER ANY FULLTEXT CATALOG |
ALTER |
CONTROL SERVER |
ALTER ANY MESSAGE TYPE |
ALTER |
CONTROL SERVER |
ALTER ANY REMOTE SERVICE BINDING |
ALTER |
CONTROL SERVER |
ALTER ANY ROLE |
ALTER |
CONTROL SERVER |
ALTER ANY ROUTE |
ALTER |
CONTROL SERVER |
ALTER ANY SCHEMA |
ALTER |
CONTROL SERVER |
ALTER ANY SERVICE |
ALTER |
CONTROL SERVER |
ALTER ANY SYMMETRIC KEY |
ALTER |
CONTROL SERVER |
ALTER ANY USER |
ALTER |
CONTROL SERVER |
AUTHENTICATE |
CONTROL |
AUTHENTICATE SERVER |
BACKUP DATABASE |
CONTROL |
CONTROL SERVER |
BACKUP LOG |
CONTROL |
CONTROL SERVER |
CHECKPOINT |
CONTROL |
CONTROL SERVER |
CONNECT |
CONNECT REPLICATION |
CONTROL SERVER |
CONNECT REPLICATION |
CONTROL |
CONTROL SERVER |
CONTROL |
CONTROL |
CONTROL SERVER |
CREATE AGGREGATE |
ALTER |
CONTROL SERVER |
CREATE ASSEMBLY |
ALTER ANY ASSEMBLY |
CONTROL SERVER |
CREATE ASYMMETRIC KEY |
ALTER ANY ASYMMETRIC KEY |
CONTROL SERVER |
CREATE CERTIFICATE |
ALTER ANY CERTIFICATE |
CONTROL SERVER |
CREATE CONTRACT |
ALTER ANY CONTRACT |
CONTROL SERVER |
CREATE DATABASE |
CONTROL |
CREATE ANY DATABASE |
CREATE DATABASE DDL EVENT NOTIFICATION |
ALTER ANY DATABASE EVENT NOTIFICATION |
CREATE DDL EVENT NOTIFICATION |
CREATE DEFAULT |
ALTER |
CONTROL SERVER |
CREATE FULLTEXT CATALOG |
ALTER ANY FULLTEXT CATALOG |
CONTROL SERVER |
CREATE FUNCTION |
ALTER |
CONTROL SERVER |
CREATE MESSAGE TYPE |
ALTER ANY MESSAGE TYPE |
CONTROL SERVER |
CREATE PROCEDURE |
ALTER |
CONTROL SERVER |
CREATE QUEUE |
ALTER |
CONTROL SERVER |
CREATE REMOTE SERVICE BINDING |
ALTER ANY REMOTE SERVICE BINDING |
CONTROL SERVER |
CREATE ROLE |
ALTER ANY ROLE |
CONTROL SERVER |
CREATE ROUTE |
ALTER ANY ROUTE |
CONTROL SERVER |
CREATE RULE |
ALTER |
CONTROL SERVER |
CREATE SCHEMA |
ALTER ANY SCHEMA |
CONTROL SERVER |
CREATE SERVICE |
ALTER ANY SERVICE |
CONTROL SERVER |
CREATE SYMMETRIC KEY |
ALTER ANY SYMMETRIC KEY |
CONTROL SERVER |
CREATE SYNONYM |
ALTER |
CONTROL SERVER |
CREATE TABLE |
ALTER |
CONTROL SERVER |
CREATE TYPE |
ALTER |
CONTROL SERVER |
CREATE VIEW |
ALTER |
CONTROL SERVER |
CREATE XML SCHEMA COLLECTION |
ALTER |
CONTROL SERVER |
DELETE |
CONTROL |
CONTROL SERVER |
EXECUTE |
CONTROL |
CONTROL SERVER |
INSERT |
CONTROL |
CONTROL SERVER |
KILL DATABASE CONNECTION 只適用於 Windows Azure SQL Database。 |
CONTROL |
ALTER ANY CONNECTION |
REFERENCES |
CONTROL |
CONTROL SERVER |
SELECT |
CONTROL |
CONTROL SERVER |
SHOWPLAN |
CONTROL |
ALTER TRACE |
SUBSCRIBE QUERY NOTIFICATIONS |
CONTROL |
CONTROL SERVER |
TAKE OWNERSHIP |
CONTROL |
CONTROL SERVER |
UPDATE |
CONTROL |
CONTROL SERVER |
VIEW DATABASE STATE |
CONTROL |
VIEW SERVER STATE |
VIEW DEFINITION |
CONTROL |
VIEW ANY DEFINITION |
權限
執行這個陳述式的主體 (或指定了 AS 選項的主體) 必須具有資料庫的 CONTROL 權限,或是具有隱含資料庫 CONTROL 權限的更高權限。
如果是使用 AS 選項,指定的主體必須擁有資料庫。
範例
A.拒絕建立憑證的權限
下列範例會對使用者 MelanieK 拒絕資料庫 AdventureWorks2012 的 CREATE CERTIFICATE 權限。
USE AdventureWorks2012;
DENY CREATE CERTIFICATE TO MelanieK;
GO
B.對應用程式角色拒絕 REFERENCES 權限
下列範例會對應用程式角色 AuditMonitor 拒絕資料庫 AdventureWorks2012 的 REFERENCES 權限。
USE AdventureWorks2012;
DENY REFERENCES TO AuditMonitor;
GO
C.拒絕具有 CASCADE 的 VIEW DEFINITION
下列範例對於使用者 CarmineEs 以及已經由 CarmineEs 授與 VIEW DEFINITION 權限的所有主體,拒絕在 AdventureWorks2012 資料庫上的 VIEW DEFINITION 權限。
USE AdventureWorks2012;
DENY VIEW DEFINITION TO CarmineEs CASCADE;
GO
請參閱
參考
sys.database_permissions (Transact-SQL)
sys.database_principals (Transact-SQL)
CREATE DATABASE (Transact-SQL)