<p>MySQL throws error 1361 when you try to create, alter, or drop a trigger on a view or temporary table.</p>
<p>MySQL Error 1361 ER_TRG_ON_VIEW_OR_TEMP_TABLE appears when a trigger targets a view or temporary table, which MySQL forbids. Create the trigger on an underlying base table or convert the view into a permanent table to resolve the issue.</p>
Trigger's '%s' is view or temporary table
MySQL raises error 1361 with the message Trigger's '%s' is view or temporary table when a CREATE TRIGGER, ALTER TRIGGER, or DROP TRIGGER statement references a view or a temporary table. MySQL allows triggers only on permanent base tables, so any attempt on unsupported objects fails immediately.
This restriction exists because views and temporary tables lack the persistent metadata and binary logging guarantees required for reliable trigger execution and replication. Fixing the error is therefore essential to maintain data integrity and avoid replication inconsistencies.
The error is triggered when the object named in the ON clause of a trigger statement is a view instead of a physical table.
It also occurs if the object is a TEMPORARY TABLE created in the current session, as MySQL blocks triggers on such transient structures.
Identify the view or temporary table and switch the trigger to a real table that stores the data. If you need trigger-like behavior on a view, create triggers on the underlying base table that feeds the view.
If using a TEMPORARY TABLE for staging, move the logic into application code or load data into a permanent staging table where a trigger is allowed.
Reporting views often need audit trails. Add AFTER INSERT triggers to the source fact table, not the reporting view, to capture changes.
Data-loading scripts that populate TEMPORARY TABLES cannot rely on triggers. Replace the temporary table with a permanent staging table and drop it after processing if space is a concern.
Always design triggers around permanent tables that underpin views. Document table ownership so developers know where to attach business logic.
Use code reviews or automated linting in Galaxy to flag CREATE TRIGGER statements that target non-base tables before they reach production.
Error 1359 (ER_TRG_ALREADY_EXISTS) arises when a duplicate trigger name is used on the same table. Drop or rename the existing trigger.
Error 1360 (ER_TRG_DOES_NOT_EXIST) appears when attempting to drop a non-existent trigger. Verify the trigger name in INFORMATION_SCHEMA.TRIGGERS.
The CREATE TRIGGER statement references a view instead of a physical table.
The developer creates a TEMPORARY TABLE for staging and mistakenly adds a trigger to it.
ORM or migration scripts generate trigger DDL without verifying that the destination is a base table.
Occurs when attempting to create a trigger that already exists on the same table and timing event.
Raised when dropping or altering a trigger that MySQL cannot find in the current database.
Happens when the user lacks the TRIGGER privilege on the target database.
No. MySQL forbids triggers on views. Move the logic to the underlying base table.
Temporary tables are session-scoped and not binary-logged, so triggers on them would break replication and persistence guarantees.
Galaxy's SQL linting flags CREATE TRIGGER statements targeting views or temporary tables before deployment, avoiding runtime failures.
Create AFTER INSERT or AFTER UPDATE triggers on the source table feeding the view, then query the audit table for changes.