![]() ![]() Extension(s) can come out of box and they can be created too. ![]() Once extension is loaded into the database, it can function as built-in feature. An extension is used for bundling multiple SQL objects together in a single package that can be loaded or removed from the database. We can also mark a trigger as dependent on an extension. Let us see an example to rename a trigger ALTER TRIGGER stocks_trigger The ALTER TRIGGER clause is followed by old trigger name, followed by the table name, followed by new trigger name after the RENAME TO clause. To rename a trigger, here is the syntax: ALTER TRIGGER trigger_name We will look at renaming a trigger and using a trigger with an extension. The Alter Trigger clause is used to modify properties of a trigger as shown below. Lets us now drop the trigger and cross verify Let us drop the trigger we created in Part 1 of this tutorial, DROP TRIGGER IF EXISTS stocks_trigger RESTRICT prevents deletion of any associated object, and this is the default. CASCADE is used to drop all objects associated with the trigger. Next the table_name is specified on which the trigger is active, followed by the condition CASCADE or RESTRICT. The IF EXISTS clause is used to avoid any unnecessary error which can result in attempting to delete any non existing trigger. In this syntax, the name of the trigger that is to be dropped is specified after the DROP TRIGGER clause. For instance in this example there is one trigger function associated to this trigger which will also get dropped. A trigger can be dropped either via the PgAdmin GUI or via queries using PSql shell or PgAdmin's query editor as shown below:įrom this menu, one can use the Delete/Drop option to drop the trigger only or one can use the Drop Cascade option to drop all associated objects at the same time in one go. The Drop Trigger command is used to remove an existing trigger from the database. If you haven't read it already, here's a link to the article: PostgreSQL Drop Trigger In the 1st part of this series, we got an overall view of database triggers, PostgreSQL-specific triggers, types of PostgreSQL triggers, and how to create a trigger with basic syntax and examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |