SQLSTATE 42710 ERROR Class 42: Syntax Error or Access Rule Violation

duplicate_object trigger “…” for relation “…” already exists — 42710

PostgreSQL error "trigger "…" for relation "…" already exists" (SQLSTATE 42710): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A CREATE TRIGGER tried to create a trigger whose name already exists on the relation. PostgreSQL raises SQLSTATE 42710 (duplicate_object).

  • A trigger with that name already exists on the table.
  • Trigger names are unique per relation.
  • Common in re-run migrations.

What the server log shows

ERROR:  trigger "audit_orders" for relation "orders" already exists

Why PostgreSQL raises this — what the manual says

As the CREATE TRIGGER reference (Description) explains:

A trigger of that name already exists on the table; trigger names are local to a table, so each must be unique per table — drop or rename the existing trigger, or use CREATE OR REPLACE TRIGGER.

Trigger names are unique within a relation. Creating one whose name is already present collides with the existing trigger, so PostgreSQL reports 42710.

Common causes

  • Re-running a migration that creates the trigger.
  • Two triggers sharing a name on the same table.
  • Forgetting to drop the prior trigger before recreating.

How to fix it

  1. Use CREATE OR REPLACE TRIGGER to redefine it (PG14+).
  2. DROP TRIGGER IF EXISTS … ON table before recreating.
  3. Choose a unique trigger name.

Related & next steps

Reference: PostgreSQL 18 — CREATE TRIGGER.

Was this helpful?