SQLite DROP Trigger
Now we will see how we can delete a trigger using the DROP TRIGGER Statement of SQLite. The generic syntax of DROP TRIGGER statement is below:
Syntax:
DROP TRIGGER <Trigger_Name>;
The syntax is pretty simple, after the DROP TRIGGER command we just simply need to pass the Trigger name which we want to delete. For this example, we will DROP the latest trigger i.e Audit_Student_Deletion.
Query:
DROP TRIGGER Audit_Student_Deletion;
Now we will check the list of triggers to see it has been successfully deleted or not.
Query:
SELECT name FROM sqlite_master WHERE type = 'trigger';
Output:
Explanation: We can clearly see in the output that the trigger Audit_Student_Deletion has been successfully deleted.
SQLite Triggers
SQLite is an embedded database that doesn’t use a database like Oracle in the background to operate. It is written in C language and is used by developers who embed a lightweight database over the existing application, browser, or embedded systems. The main features of SQLite are that it is a tiny, quick, self-contained, reliable, full-featured SQL database engine.
A trigger is a schema object that gets executed or “triggered” automatically when SQLite commands like INSERT, UPDATE, or DELETE are executed against a certain table. Triggers are mostly used in complex infrastructure that involves several databases and their tables, to keep a log of the changes made in that database or tables. Triggers can also be used to prevent invalid transactions in case of important and sensitive databases or tables.
In this article, We will see how we can create a trigger in SQLite and some of the examples where a trigger can be used, also we will see how we can delete the trigger using the DROP command.
Contact Us