Site icon Database Tutorials

PostgreSQL DDL Trigger\Event Trigger

In today’s article, we will explain PostgreSQL DDL Trigger and Event Trigger structures with the help of examples.

Data Definition Language (DDL) tables are used to define the database structure or schema.

Some of these are as follows.

Operations such as CREATE, ALTER, DROP and TRUNCATE.

Sometimes we want to keep a record of DDL operations.

Therefore, we have to use operations such as triggers.

First, we create the table where the ddl transactions will be kept.

After creating our table, let’s create our function.

Let’s create our event trigger.

Let’s create a function called deneme.

We check the ddl_log table we created, is our record added?

Let’s create a table for testing purposes.

When we look at our ddl_log table, we see that when and with which user the create table command was run is written to the table.

Exit mobile version