[1] DML Triggers Flashcards

1
Q

What does DML mean?

A

Data Manipulation Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Trigger and what is it’s purpose?

A

It is a type of stored procedure that responds to a specifed DML or DDL event. It can track changes performed on tables or views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name the different types of Triggers

A

AFTER and INSTEAD OF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give the syntax for a Trigger that updates, and checks row count.

A

CREATE TRIGGER dbo.TriggerName

FOR dbo.TableName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the different DML events that Triggers can detect?

A

UPDATE, INSERT, DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which tables do Triggers store manipulated data>

A

Inserted and Deleted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How many times do Triggers exectue per DML statement?

A

Once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of function can be used for auditing or enforcing integrity rules?

A

DML Triggers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What action does a ROLLBACK TRAN command perform?

A

It returns the table/view to its original state before the DML statement was executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What i are the two alternatives to a ROLLBACK TRAN command used in a TRIGGER?

A

THROW or RAISERROR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you exit a Trigger normally?

A

RETURN statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between the information stored in a system inserted table, compared to a system deleted table in an AFTER Trigger?

A

Inserted stores new information of the affected rows for INSERT and UPDATE events. Deleted stores the old information on the DELETE and UPDATE statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between the information stored in a system inserted table, compared to a system deleted table in an INSTEAD OF Trigger?

A

Both Inserted and Deleted tables stores information on the rows that would be affected by the DML statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which type of Trigger can only be defined on tables, and which can be defined on both tables and views?

A

AFTER Triggers can only be defined on tables. INSTEAD OF can be defined on both tables and views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does the Trigger test whether any rows have been altered?

A

With the use of an @@ROWCOUNT = 0 test as the first line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a nested AFTER Trigger? and how many can you have?

A

A Trigger in a Trigger. You can have 32 nested triggers.