Javatpoint Logo
Javatpoint Logo

PostgreSQL ENABLE TRIGGER

In this section, we are going to understand the working of the Enable trigger using the ALTER TABLE command and see the example of it.

What is PostgreSQL ENABLE TRIGGER command?

If we want to enable a trigger, we will use the ENABLE TRIGGER command with the ALTER TABLE command.

The Syntax of PostgreSQL Enable Trigger using ALTER TRIGGER command

The syntax PostgreSQL Enable Trigger using ALTER TRIGGER command is as follows:

In the above syntax, we have used the following parameters, as shown in the below table:

Parameters Description
Table_name It is used to define the table name where the trigger is linked. And it is mentioned after the ALTER TABLE keywords.
Trigger_name It is used to define the trigger name, which we want to enable it. And it can be written after the ENABLE TRIGGER keywords.
And to enable all triggers linked with the table, we can use the ALL keyword as well.

Note: The PostgreSQL disabled trigger doesn't execute when the triggering event occurs, and to make it implemented, we need to enable it.

Example of PostgreSQL ENABLE TRIGGER using ALTER TABLE command

Let us see a simple example to understand the working of the PostgreSQL ENABLE Trigger command.

  • Using Trigger name

In the following example, we are taking a similar Clients table, which we used in the PostgreSQL Disable trigger section of the PostgreSQL tutorial.

If we want to enable the trigger connected with the Client table, as shown in the below command:

Output

On implementing the above command, we will get the following window message, which displays that the First_name_changes trigger with the Clients table has been enabled successfully.

PostgreSQL ENABLE Trigger
  • Using ALL keyword instead of the trigger name

And, if we want to enable all triggers linked with the Clients table, we can use the below command:

Output

After implementing the above command, we will get the following message window, which displays that all the associated trigger has been enabled successfully into the Clients table.

PostgreSQL ENABLE Trigger

Overview

In the PostgreSQL Enable Trigger section, we have learned the following topics:

  • We have used PostgreSQL ENABLE TRIGGERwith ALTER TABLE command to enable a trigger with the help of a particular trigger name linked with the specified table.
  • And instead of using the trigger name, we can use the ALL keyword to enable all the triggers linked with a particular table.

Next TopicPostgreSQL Indexes





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA