Data Definition Language (DDL) triggers are fired in response to events caused by DDL statements like CREATE, ALTER, and DROP. These can be created at either the database level or server level, and can also be triggered by system-defined stored procedures that execute actions similar to DDL statements.
These triggers are helpful because:
1. sometimes it is necessary to avoid altering the database schema. 2. sometimes it is necessary to review database schema modifications. 3. sometimes we must respond to a modification made in the database schema.
An example of a DDL trigger that prevents the user from deleting a table in a database would be as follows:
CREATE TRIGGER PreventDrop
ON DATABASE
FOR DROP_TABLE
AS
PRINT 'Error: Table cannot be dropped!'
ROLLBACK
;
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Data Definition Language (DDL) triggers are fired in response to events caused by DDL statements like CREATE, ALTER, and DROP. These can be created at either the database level or server level, and can also be triggered by system-defined stored procedures that execute actions similar to DDL statements.
These triggers are helpful because:
1. sometimes it is necessary to avoid altering the database schema.
2. sometimes it is necessary to review database schema modifications.
3. sometimes we must respond to a modification made in the database schema.
An example of a DDL trigger that prevents the user from deleting a table in a database would be as follows: