DDL 事件DDL Events

适用于: 是SQL Server是Azure SQL 数据库否Azure SQL 数据仓库否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

下表列出了可用于激发 DDL 触发器或事件通知的 DDL 事件。The following tables list the DDL events that can be used to fire a DDL trigger or event notification. 注意,每个事件都对应于一个 Transact-SQLTransact-SQL 语句或存储过程,并且语句语法修改为在关键字之间加入了一个下划线字符 ()。Note that each event corresponds to a Transact-SQLTransact-SQL statement or stored procedure, with the statement syntax modified to include an underscore character () between keywords.

重要

执行类似 DDL 的操作的系统存储过程也可以激发 DDL 触发器和事件通知。System stored procedures that perform DDL-like operations also fire DDL triggers and event notifications. 请测试您的 DDL 触发器和事件通知以确定它们是否响应运行的系统存储过程。Test your DDL triggers and event notifications to determine their responses to system stored procedures that are run. 例如,CREATE TYPE 语句和 sp_addtype 存储过程都将激发针对 CREATE_TYPE 事件创建的 DDL 触发器或事件通知。For example, the CREATE TYPE statement and sp_addtype stored procedure will both fire a DDL trigger or event notification that is created on a CREATE_TYPE event.

具有服务器或数据库作用域的 DDL 语句DDL Statements That Have Server or Database Scope

可以创建 DDL 触发器或事件通知,以便在其中创建了它们的数据库发生以下事件(或服务器实例中的任何位置发生以下事件时)激发它们以做出响应。DDL triggers or event notifications can be created to fire in response to the following events when they occur in the database in which the trigger or event notification is created, or anywhere in the server instance.

CREATE_APPLICATION_ROLE(适用于 CREATE APPLICATION ROLE 语句和 sp_addapproleCREATE_APPLICATION_ROLE (Applies to the CREATE APPLICATION ROLE statement and sp_addapprole. 如果创建新架构,则此事件还会触发 CREATE_SCHEMA 事件)。If a new schema is created, this event also triggers a CREATE_SCHEMA event.) ALTER_APPLICATION_ROLE(适用于 ALTER APPLICATION ROLE 语句和 sp_approlepassword)。ALTER_APPLICATION_ROLE (Applies to the ALTER APPLICATION ROLE statement and sp_approlepassword.) DROP_APPLICATION_ROLE(适用于 DROP APPLICATION ROLE 语句和 sp_dropapprole)。DROP_APPLICATION_ROLE (Applies to the DROP APPLICATION ROLE statement and sp_dropapprole.)
CREATE_ASSEMBLYCREATE_ASSEMBLY ALTER_ASSEMBLYALTER_ASSEMBLY DROP_ASSEMBLYDROP_ASSEMBLY
CREATE_ASYMMETRIC_KEYCREATE_ASYMMETRIC_KEY ALTER_ASYMMETRIC_KEYALTER_ASYMMETRIC_KEY DROP_ASYMMETRIC_KEYDROP_ASYMMETRIC_KEY
ALTER_AUTHORIZATIONALTER_AUTHORIZATION ALTER_AUTHORIZATION_DATABASE(当指定 ON DATABASE 时,适用于 ALTER AUTHORIZATION 语句和 sp_changedbowner。)ALTER_AUTHORIZATION_DATABASE (Applies to the ALTER AUTHORIZATION statement when ON DATABASE is specified, and sp_changedbowner.)
CREATE_BROKER_PRIORITYCREATE_BROKER_PRIORITY CREATE_BROKER_PRIORITYCREATE_BROKER_PRIORITY CREATE_BROKER_PRIORITYCREATE_BROKER_PRIORITY
CREATE_CERTIFICATECREATE_CERTIFICATE ALTER_CERTIFICATEALTER_CERTIFICATE DROP_CERTIFICATEDROP_CERTIFICATE
CREATE_CONTRACTCREATE_CONTRACT DROP_CONTRACTDROP_CONTRACT
CREATE_CREDENTIALCREATE_CREDENTIAL ALTER_CREDENTIALALTER_CREDENTIAL DROP_CREDENTIALDROP_CREDENTIAL
GRANT_DATABASEGRANT_DATABASE DENY_DATABASEDENY_DATABASE REVOKE_DATABASEREVOKE_DATABASE
CREATE_DATABASE_AUDIT_SPEFICIATIONCREATE_DATABASE_AUDIT_SPEFICIATION ALTER_DATABASE_AUDIT_SPEFICIATIONALTER_DATABASE_AUDIT_SPEFICIATION DENY_DATABASE_AUDIT_SPEFICIATIONDENY_DATABASE_AUDIT_SPEFICIATION
CREATE_DATABASE_ENCRYPTION_KEYCREATE_DATABASE_ENCRYPTION_KEY ALTER_DATABASE_ENCRYPTION_KEYALTER_DATABASE_ENCRYPTION_KEY DROP_DATABASE_ENCRYPTION_KEYDROP_DATABASE_ENCRYPTION_KEY
CREATE_DEFAULTCREATE_DEFAULT DROP_DEFAULTDROP_DEFAULT
BIND_DEFAULT(适用于 sp_bindefault。)BIND_DEFAULT (Applies to sp_bindefault.) UNBIND_DEFAULT(适用于 sp_unbindefault。)UNBIND_DEFAULT (Applies to sp_unbindefault.)
CREATE_EVENT_NOTIFICATIONCREATE_EVENT_NOTIFICATION DROP_EVENT_NOTIFICATIONDROP_EVENT_NOTIFICATION
CREATE_EXTENDED_PROPERTY(适用于 sp_addextendedproperty。)CREATE_EXTENDED_PROPERTY (Applies to sp_addextendedproperty.) ALTER_EXTENDED_PROPERTY(适用于 sp_updateextendedproperty。)ALTER_EXTENDED_PROPERTY (Applies to sp_updateextendedproperty.) DROP_EXTENDED_PROPERTY(适用于 sp_dropextendedproperty。)DROP_EXTENDED_PROPERTY (Applies to sp_dropextendedproperty.)
CREATE_FULLTEXT_CATALOG(当指定 create 时适用于 CREATE FULLTEXT CATALOG 语句和 sp_fulltextcatalog。)CREATE_FULLTEXT_CATALOG (Applies to the CREATE FULLTEXT CATALOG statement and sp_fulltextcatalog when create is specified.) ALTER_FULLTEXT_CATALOG(当指定 start_incremental、 start_full、 Stop 或 Rebuild 时,适用于 ALTER FULLTEXT CATALOG 语句 sp_fulltextcatalog,当指定 enable 时,适用于 sp_fulltext_database。)ALTER_FULLTEXT_CATALOG (Applies to the ALTER FULLTEXT CATALOG statement, sp_fulltextcatalog when start_incremental, start_full, Stop, or Rebuild is specified, and sp_fulltext_database when enable is specified.) DROP_FULLTEXT_CATALOG(当指定 drop 时,适用于 DROP FULLTEXT CATALOG 语句和 sp_fulltextcatalog。)DROP_FULLTEXT_CATALOG (Applies to the DROP FULLTEXT CATALOG statement and sp_fulltextcatalog when drop is specified.)
CREATE_FULLTEXT_INDEX(当指定 create 时,适用于 CREATE FULLTEXT INDEX 语句和 sp_fulltexttable。)CREATE_FULLTEXT_INDEX (Applies to the CREATE FULLTEXT INDEX statement and sp_fulltexttable when create is specified.) ALTER_FULLTEXT_INDEX(当指定 start_full 、start_incremental 或 stop 时,适用于 ALTER FULLTEXT INDEX 语句和 sp_fulltextcatalog,当指定除了 create 或 drop 操作之外时,适用于 sp_fulltext_columnsp_fulltext_table。)ALTER_FULLTEXT_INDEX (Applies to the ALTER FULLTEXT INDEX statement, sp_fulltextcatalog when start_full, start_incremental, or stop is specified, sp_fulltext_column, and sp_fulltext_table when any action other than create or drop is specified.) DROP_FULLTEXT_INDEX(当指定 drop 时,适用于 DROP FULLTEXT INDEX 语句和 sp_fulltexttable。)DROP_FULLTEXT_INDEX (Applies to the DROP FULLTEXT INDEX statement and sp_fulltexttable when drop is specified.)
CREATE_FULLTEXT_STOPLISTCREATE_FULLTEXT_STOPLIST ALTER_FULLTEXT_STOPLISTALTER_FULLTEXT_STOPLIST DROP_FULLTEXT_STOPLISTDROP_FULLTEXT_STOPLIST
CREATE_FUNCTIONCREATE_FUNCTION ALTER_FUNCTIONALTER_FUNCTION DROP_FUNCTIONDROP_FUNCTION
CREATE_INDEXCREATE_INDEX ALTER_INDEX(适用于ALTER INDEX 语句和 sp_indexoption。)ALTER_INDEX (Applies to the ALTER INDEX statement and sp_indexoption.) DROP_INDEXDROP_INDEX
CREATE_MASTER_KEYCREATE_MASTER_KEY ALTER_MASTER_KEYALTER_MASTER_KEY DROP_MASTER_KEYDROP_MASTER_KEY
CREATE_MESSAGE_TYPECREATE_MESSAGE_TYPE ALTER_MESSAGE_TYPEALTER_MESSAGE_TYPE DROP_MESSAGE_TYPEDROP_MESSAGE_TYPE
CREATE_PARTITION_FUNCTIONCREATE_PARTITION_FUNCTION ALTER_PARTITION_FUNCTIONALTER_PARTITION_FUNCTION DROP_PARTITION_FUNCTIONDROP_PARTITION_FUNCTION
CREATE_PARTITION_SCHEMECREATE_PARTITION_SCHEME ALTER_PARTITION_SCHEMEALTER_PARTITION_SCHEME DROP_PARTITION_SCHEMEDROP_PARTITION_SCHEME
CREATE_PLAN_GUIDE(适用于 sp_create_plan_guide。)CREATE_PLAN_GUIDE (Applies to sp_create_plan_guide.) ALTER_PLAN_GUIDE(当指定 ENABLE、ENABLE ALL、DISABLE 或 DISABLE ALL 时适用于 sp_control_plan_guide 。)ALTER_PLAN_GUIDE (Applies to sp_control_plan_guide when ENABLE, ENABLE ALL, DISABLE, or DISABLE ALL is specified.) DROP_PLAN_GUIDE(当指定 DROP 或 DROP ALL 时适用于 sp_control_plan_guide 。)DROP_PLAN_GUIDE (Applies to sp_control_plan_guide when DROP or DROP ALL is specified.)
CREATE_PROCEDURECREATE_PROCEDURE ALTER_PROCEDURE(适用于 ALTER PROCEDURE 语句和 sp_procoption。)ALTER_PROCEDURE (Applies to the ALTER PROCEDURE statement and sp_procoption.) DROP_PROCEDUREDROP_PROCEDURE
CREATE_QUEUECREATE_QUEUE ALTER_QUEUEALTER_QUEUE DROP_QUEUEDROP_QUEUE
CREATE_REMOTE_SERVICE_BINDINGCREATE_REMOTE_SERVICE_BINDING ALTER_REMOTE_SERVICE_BINDINGALTER_REMOTE_SERVICE_BINDING DROP_REMOTE_SERVICE_BINDINGDROP_REMOTE_SERVICE_BINDING
CREATE_SPATIAL_INDEXCREATE_SPATIAL_INDEX
RENAME(适用于 sp_renameRENAME (Applies to sp_rename)
CREATE_ROLE(适用于 CREATE ROLE 语句、 sp_addrolesp_addgroup。)CREATE_ROLE (Applies to the CREATE ROLE statement, sp_addrole, and sp_addgroup.) ALTER_ROLEALTER_ROLE DROP_ROLE(适用于 DROP ROLE 语句、 sp_droprolesp_dropgroup。)DROP_ROLE (Applies to the DROP ROLE statement, sp_droprole, and sp_dropgroup.)
ADD_ROLE_MEMBERADD_ROLE_MEMBER DROP_ROLE_MEMBERDROP_ROLE_MEMBER
CREATE_ROUTECREATE_ROUTE ALTER_ROUTEALTER_ROUTE DROP_ROUTEDROP_ROUTE
CREATE_RULECREATE_RULE DROP_RULEDROP_RULE
BIND_RULE(适用于 sp_bindrule。)BIND_RULE (Applies to sp_bindrule.) UNBIND_RULE(适用于 sp_unbindrule。)UNBIND_RULE (Applies to sp_unbindrule.)
CREATE_SCHEMA(适用于 CREATE SCHEMA 语句、sp_addrole sp_addusersp_addgroupsp_grantdbaccess。)CREATE_SCHEMA (Applies to the CREATE SCHEMA statement, sp_addrole, sp_adduser, sp_addgroup, and sp_grantdbaccess.) ALTER_SCHEMA(适用于 ALTER SCHEMA 语句和 sp_changeobjectowner)。ALTER_SCHEMA (Applies to the ALTER SCHEMA statement and sp_changeobjectowner.) DROP_SCHEMADROP_SCHEMA
CREATE_SEARCH_PROPERTY_LISTCREATE_SEARCH_PROPERTY_LIST ALTER_SEARCH_PROPERTY_LISTALTER_SEARCH_PROPERTY_LIST DROP_SEARCH_PROPERTY_LISTDROP_SEARCH_PROPERTY_LIST
CREATE_SEQUENCE_EVENTSCREATE_SEQUENCE_EVENTS CREATE_SEQUENCE_EVENTSCREATE_SEQUENCE_EVENTS CREATE_SEQUENCE_EVENTSCREATE_SEQUENCE_EVENTS
CREATE_SERVER_ROLECREATE_SERVER_ROLE ALTER_SERVER_ROLEALTER_SERVER_ROLE DROP_SERVER_ROLEDROP_SERVER_ROLE
CREATE_SERVICECREATE_SERVICE ALTER_SERVICEALTER_SERVICE DROP_SERVICEDROP_SERVICE
ALTER_SERVICE_MASTER_KEYALTER_SERVICE_MASTER_KEY BACKUP_SERVICE_MASTER_KEYBACKUP_SERVICE_MASTER_KEY RESTORE_SERVICE_MASTER_KEYRESTORE_SERVICE_MASTER_KEY
ADD_SIGNATURE(用于对非架构范围的对象的签名操作;数据库,程序集,触发器)ADD_SIGNATURE (for signature operations on non-schema scoped objects; database, assembly, trigger) DROP_SIGNATUREDROP_SIGNATURE
ADD_SIGNATURE_SCHEMA_OBJECT(用于架构范围的对象;存储过程,函数)ADD_SIGNATURE_SCHEMA_OBJECT (for schema scoped objects; stored procedures, functions) DROP_SIGNATURE_SCHEMA_OBJECTDROP_SIGNATURE_SCHEMA_OBJECT
CREATE_SPATIAL_INDEXCREATE_SPATIAL_INDEX ALTER_INDEX 可用于空间索引。ALTER_INDEX can be used for spatial indexes. DROP_INDEX 可用于空间索引。DROP_INDEX can be used for spatial indexes.
CREATE_STATISTICSCREATE_STATISTICS DROP_STATISTICSDROP_STATISTICS UPDATE_STATISTICSUPDATE_STATISTICS
CREATE_SYMMETRIC_KEYCREATE_SYMMETRIC_KEY ALTER_SYMMETRIC_KEYALTER_SYMMETRIC_KEY DROP_SYMMETRIC_KEYDROP_SYMMETRIC_KEY
CREATE_SYNONYMCREATE_SYNONYM DROP_SYNONYMDROP_SYNONYM
CREATE_TABLECREATE_TABLE ALTER_TABLE(适用于 ALTER TABLE 语句和 sp_tableoption。)ALTER_TABLE (Applies to the ALTER TABLE statement and sp_tableoption.) DROP_TABLEDROP_TABLE
CREATE_TRIGGERCREATE_TRIGGER ALTER_TRIGGER(适用于 ALTER TRIGGER 语句和 sp_settriggerorder。)ALTER_TRIGGER (Applies to the ALTER TRIGGER statement and sp_settriggerorder.) DROP_TRIGGERDROP_TRIGGER
CREATE_TYPE(适用于 CREATE TYPE 语句和 sp_addtypeCREATE_TYPE (Applies to the CREATE TYPE statement and sp_addtype.) DROP_TYPE(适用于 DROP TYPE 语句和 sp_droptype。)DROP_TYPE (Applies to the DROP TYPE statement and sp_droptype.)
CREATE_USER(适用于 CREATE USER 语句、 sp_addusersp_grantdbaccessCREATE_USER (Applies to the CREATE USER statement, sp_adduser, and sp_grantdbaccess.) ALTER_USER(应用于 ALTER USER 语句和 sp_change_users_login。)ALTER_USER (Applies to ALTER USER statement and sp_change_users_login.) DROP_USER(适用于 DROP USER 语句、 sp_dropusersp_revokedbaccess。)DROP_USER (Applies to the DROP USER statement, sp_dropuser, and sp_revokedbaccess.)
CREATE_VIEWCREATE_VIEW ALTER_VIEWALTER_VIEW DROP_VIEWDROP_VIEW
CREATE_XML_INDEXCREATE_XML_INDEX ALTER_INDEX 可用于 XML 索引。ALTER_INDEX can be used for XML indexes. DROP_INDEX 可用于 XML 索引。DROP_INDEX can be used for XML indexes.
CREATE_XML_SCHEMA_COLLECTIONCREATE_XML_SCHEMA_COLLECTION ALTER_XML_SCHEMA_COLLECTIONALTER_XML_SCHEMA_COLLECTION DROP_XML_SCHEMA_COLLECTIONDROP_XML_SCHEMA_COLLECTION

具有服务器作用域的 DDL 语句DDL Statements That Have Server Scope

可以创建当服务器实例中的任何位置发生以下事件时被激发以响应这些事件的 DDL 触发器或事件通知。DDL triggers or event notifications can be created to fire in response to the following events when they occur anywhere in the server instance.

ALTER_AUTHORIZATION_SERVERALTER_AUTHORIZATION_SERVER ALTER_SERVER_CONFIGURATIONALTER_SERVER_CONFIGURATION ALTER_INSTANCE(当指定了本地服务器实例时,适用于 sp_configuresp_addserver 。)ALTER_INSTANCE (Applies to sp_configure and sp_addserver when a local server instance is specified.)
CREATE_AVAILABILITY_GROUPCREATE_AVAILABILITY_GROUP ALTER_AVAILABILITY_GROUPALTER_AVAILABILITY_GROUP DROP_AVAILABILITY_GROUPDROP_AVAILABILITY_GROUP
CREATE_CREDENTIALCREATE_CREDENTIAL ALTER_CREDENTIALALTER_CREDENTIAL DROP_CREDENTIALDROP_CREDENTIAL
CREATE_CRYPTOGRAPHIC_PROVIDERCREATE_CRYPTOGRAPHIC_PROVIDER ALTER_CRYPTOGRAPHIC_PROVIDERALTER_CRYPTOGRAPHIC_PROVIDER DROP_CRYPTOGRAPHIC_PROVIDERDROP_CRYPTOGRAPHIC_PROVIDER
CREATE_DATABASECREATE_DATABASE ALTER_DATABASE(适用于 ALTER DATABASE 语句和 sp_fulltext_database。)ALTER_DATABASE (Applies to the ALTER DATABASE statement and sp_fulltext_database.) DROP_DATABASEDROP_DATABASE
CREATE_ENDPOINTCREATE_ENDPOINT ALTER_ENDPOINTALTER_ENDPOINT DROP_ENDPOINTDROP_ENDPOINT
CREATE_EVENT_SESSIONCREATE_EVENT_SESSION ALTER_EVENT_SESSIONALTER_EVENT_SESSION DROP_EVENT_SESSIONDROP_EVENT_SESSION
CREATE_EXTENDED_PROCEDURE(适用于 sp_addextendedproc。)CREATE_EXTENDED_PROCEDURE (Applies to sp_addextendedproc.) DROP_EXTENDED_PROCEDURE(适用于 sp_dropextendedproc。)DROP_EXTENDED_PROCEDURE (Applies to sp_dropextendedproc.)
CREATE_LINKED_SERVER(适用于 sp_addlinkedserver。)CREATE_LINKED_SERVER (Applies to sp_addlinkedserver.) ALTER_LINKED_SERVER(适用于 sp_serveroption。)ALTER_LINKED_SERVER (Applies to sp_serveroption.) DROP_LINKED_SERVER(当指定了链接服务器时,适用于 sp_dropserver 。)DROP_LINKED_SERVER (Applies to sp_dropserver when a linked server is specified.)
CREATE_LINKED_SERVER_LOGIN(适用于 sp_addlinkedsrvlogin。)CREATE_LINKED_SERVER_LOGIN (Applies to sp_addlinkedsrvlogin.) DROP_LINKED_SERVER_LOGIN(适用于 sp_droplinkedsrvlogin。)DROP_LINKED_SERVER_LOGIN (Applies to sp_droplinkedsrvlogin.)
CREATE_LOGIN(当使用必须隐式创建的不存在登录名时,适用于 CREATE LOGIN 语句、sp_addlogin sp_grantlogin xp_grantloginsp_denylogin。)CREATE_LOGIN (Applies to the CREATE LOGIN statement, sp_addlogin, sp_grantlogin, xp_grantlogin, and sp_denylogin when used on a nonexistent login that must be implicitly created.) ALTER_LOGIN(当指定 Auto_Fix 时,适用于sp_defaultdbsp_defaultlanguagesp_passwordsp_change_users_login。)ALTER_LOGIN (Applies to the ALTER LOGIN statement, sp_defaultdb, sp_defaultlanguage, sp_password, and sp_change_users_login when Auto_Fix is specified.) DROP_LOGIN(适用于 DROP LOGIN 语句、sp_droploginsp_revokeloginxp_revokeloginDROP_LOGIN (Applies to the DROP LOGIN statement, sp_droplogin, sp_revokelogin, and xp_revokelogin.)
CREATE_MESSAGE(适用于 sp_addmessage。)CREATE_MESSAGE (Applies to sp_addmessage.) ALTER_MESSAGE(适用于 sp_altermessage。)ALTER_MESSAGE (Applies to sp_altermessage.) DROP_MESSAGE(适用于 sp_dropmessage。)DROP_MESSAGE (Applies to sp_dropmessage.)
CREATE_REMOTE_SERVER(适用于 sp_addserver。)CREATE_REMOTE_SERVER (Applies to sp_addserver.) ALTER_REMOTE_SERVER(适用于 sp_setnetname。)ALTER_REMOTE_SERVER (Applies to sp_setnetname.) DROP_REMOTE_SERVER(当指定了远程服务器时,适用于 sp_dropserver 。)DROP_REMOTE_SERVER (Applies to sp_dropserver when a remote server is specified.)
CREATE_RESOURCE_POOLCREATE_RESOURCE_POOL ALTER_RESOURCE_POOLALTER_RESOURCE_POOL DROP_RESOURCE_POOLDROP_RESOURCE_POOL
GRANT_SERVERGRANT_SERVER DENY_SERVERDENY_SERVER REVOKE_SERVERREVOKE_SERVER
ADD_SERVER_ROLE_MEMBERADD_SERVER_ROLE_MEMBER DROP_SERVER_ROLE_MEMBERDROP_SERVER_ROLE_MEMBER
CREATE_SERVER_AUDITCREATE_SERVER_AUDIT ALTER_SERVER_AUDITALTER_SERVER_AUDIT DROP_SERVER_AUDITDROP_SERVER_AUDIT
CREATE_SERVER_AUDIT_SPECIFICATIONCREATE_SERVER_AUDIT_SPECIFICATION ALTER_SERVER_AUDIT_SPECIFICATIONALTER_SERVER_AUDIT_SPECIFICATION DROP_SERVER_AUDIT_SPECIFICATIONDROP_SERVER_AUDIT_SPECIFICATION
CREATE_WORKLOAD_GROUPCREATE_WORKLOAD_GROUP ALTER_WORKLOAD_GROUPALTER_WORKLOAD_GROUP DROP_WORKLOAD_GROUPDROP_WORKLOAD_GROUP

另请参阅See Also

DDL 触发器 DDL Triggers
事件通知 Event Notifications
DDL 事件组DDL Event Groups