Friday , July 19 2024


In this tutorial, you will learn how to use the PostgreSQL DELETE TRIGGER statement to delete a trigger from a table.

First of all, we need to create a function or procedure before creating the trigger.

The purpose of doing this is that we will be performing the action to be performed in the create trigger command by using that function.

Let’s make an example of the delete trigger.

When the deletion operation of the parents table is performed, we will create a trigger that writes the “id, adi, soyadi” columns in which parents table and which user did this delete operation, when he did it and what action was done in the parents audit table.

First, we create a table named Veliler_audit that will keep the log of deleted items.

After creating our table, we need to create a function as follows to add our data to the Veliler_audit table.

Here in the returns section; You can see that we used the returns trigger command.

The reason for this is because this function will be used in the trigger.

After creating our function, we create the trigger that we specified at the bottom of the function we created as follows.

Let’s delete record number 14 in the Veliler table.

Let’s check if our record has been deleted.


About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *