Wednesday, October 23, 2013

DDL TRIGGER

DDL triggers are a special kind of trigger that fire in response to Data Definition Language (DDL) statements(Create,Alter,Drop).

They can be used to perform administrative tasks in the database such as auditing and regulating database operations.

Use DDL triggers when you want to do the following:

1.You want to prevent certain changes to your database schema.

2.You want something to occur in the database in response to a change in your database schema.

3.You want to record changes or events in the database schema.



=======================

create TRIGGER safety

ON DATABASE

FOR CREATE_TABLE, DROP_TABLE, ALTER_TABLE

AS

PRINT 'You must disable Trigger "safety" to drop or alter tables!'

ROLLBACK



;

======================

alter TRIGGER safety

ON DATABASE

FOR CREATE_TABLE, DROP_TABLE, ALTER_TABLE

AS

PRINT 'You must disable Trigger "safety" to drop or alter tables!!'

ROLLBACK




;

======================

drop TRIGGER [safety] ON DATABASE;



====================

Disable TRIGGER [safety] ON DATABASE;



======================

ENABLE TRIGGER [safety] ON DATABASE;



===========================================

No comments:

Post a Comment