Câu hỏi phỏng vấn MySQL
Câu hỏi

What is a trigger. What are different type of triggers in MySQL?

Câu trả lời

A MySQL trigger is a named database object that is associated with a table and automatically activates in response to specific events on that table, such as INSERT, UPDATE, or DELETE operations[2][3][5]. Triggers are used for various purposes, including enforcing business rules, validating data, maintaining audit trails, and synchronizing tables.

Types of Triggers in MySQL

MySQL supports several types of triggers, which can be categorized based on the timing of their activation relative to the data modification event:

  1. BEFORE Triggers: These triggers activate before a specified data modification event (INSERT, UPDATE, or DELETE) occurs on the table. They are often used for validating or modifying data before it is written into the table[3][7].

  2. AFTER Triggers: These triggers activate after the data modification event. They are useful for actions that require the assurance that the data has already been modified, such as logging changes or updating other tables based on the changes in the main table[3][7].

  3. INSTEAD OF Triggers: This type of trigger is used mainly in views, not in tables. It replaces the standard action of a data modification event with custom actions defined in the trigger[1].

  4. COMPOUND Triggers: These are not explicitly mentioned in the standa...

middle

middle

Gợi ý câu hỏi phỏng vấn

middle

Both TIMESTAMP and DATETIME are used to store data and time. Explain difference between them and when
should one be used?

junior

What is self referencing foreign key? Give an example.

expert

What is the use of SAVEPOINT in MySQL?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào