DROP TRIGGER

On this page Carat arrow pointing down

The DROP TRIGGER statement drops a trigger.

Required privileges

To drop a trigger, a user must have the DROP privilege on the trigger.

Synopsis

DROP TRIGGER IF EXISTS trigger_name ON table_name RESTRICT

Parameters

Parameter Description
trigger_name The name of the trigger to drop.
table_name The name of the table associated with the trigger.

Examples

Setup

To follow along, run cockroach demo to start a temporary, in-memory cluster with the movr sample dataset preloaded:

icon/buttons/copy
$ cockroach demo

Drop a trigger

Create a sample trigger function:

icon/buttons/copy
CREATE FUNCTION update_timestamp() 
RETURNS TRIGGER AS $$
BEGIN
  RAISE NOTICE 'Current timestamp: %', now();
  RETURN NEW;
END;
$$ LANGUAGE PLpgSQL;

Create a sample trigger:

icon/buttons/copy
CREATE TRIGGER log_update_timestamp
AFTER UPDATE ON users
FOR EACH ROW
EXECUTE FUNCTION update_timestamp();

Drop the trigger:

icon/buttons/copy
DROP TRIGGER log_update_timestamp ON users;

Known limitations

DROP TRIGGER with CASCADE is not supported. #128151

See also


Yes No
On this page

Yes No