c2 BLOB,
c3 ENUM('a','b','c') CHARACTER SET binary
);
To see whether MySQL used a data type other than the one you specified, issue a
CREATE TABLE
Certain other data type changes can occur if you compress a table using myisampack. See
Section 14.1.3.3, "Compressed Table
13.1.11.
CREATE TRIGGER
CREATE
[DEFINER = {
TRIGGER
ON
tbl_name
This statement creates a new trigger. A trigger is a named database object that is associated with a
table, and that activates when a particular event occurs for the table. The trigger becomes associated
with the table named tbl_name, which must refer to a permanent table. You cannot associate a trigger
with a
TEMPORARY
In MySQL 5.0
The
DEFINER
trigger activation time. It was added in MySQL 5.0.17. See later in this section for more information.
trigger_time
activates before or after each row to be modified.
trigger_event
be one of the following:
• INSERT: The trigger is activated whenever a new row is inserted into the table; for example, through
INSERT,
LOAD
• UPDATE: The trigger is activated whenever a row is modified; for example, through
statements.
• DELETE: The trigger is activated whenever a row is deleted from the table; for example, through
and
DELETE
on the table do not activate this trigger, because they do not use DELETE. See
"TRUNCATE TABLE
It is important to understand that the
statement that activates the trigger so much as it represents a type of table operation. For example, an
trigger is activated by not only
INSERT
both statements insert rows into a table.
A potentially confusing example of this is the
UPDATE ...
AFTER INSERT
whether there was a duplicate key for the row.
There cannot be two triggers for a given table that have the same trigger action time and event. For
example, you cannot have two
and a
UPDATE
trigger_body
statements, use the
the same statements that are permissible within stored routines. See
Compound-Statement
END
"Restrictions on Stored
CREATE TRIGGER
statement after creating or altering the table.
Syntax
user
| CURRENT_USER }]
trigger_name trigger_time trigger_event
FOR EACH ROW
trigger_body
table or a view.
CREATE TRIGGER
requires the
CREATE TRIGGER
clause determines the security context to be used when checking access privileges at
is the trigger action time. It can be
indicates the kind of statement that activates the trigger. The
DATA, and
REPLACE
statements. However,
REPLACE
Syntax".
syntax: a
BEFORE INSERT
trigger or both the
BEFORE UPDATE
BEFORE UPDATE
trigger, or a
BEFORE INSERT
is the statement to execute when the trigger activates. If you want to execute multiple
BEGIN ... END
Syntax". Some statements are not permitted in triggers; see
Programs".
Syntax
Characteristics".
was added in MySQL 5.0.2.
[578]
SUPER
BEFORE
statements.
DROP TABLE
does not represent a literal type of SQL
trigger_event
statements but also
INSERT
INSERT INTO ... ON DUPLICATE KEY
trigger will activate for every row, followed by either an
and
AFTER UPDATE
triggers for a table. But you can have a
BEFORE UPDATE
compound statement construct. This also enables you to use
1047
privilege.
or
to indicate that the trigger
AFTER
trigger_event
and
TRUNCATE TABLE
Section 13.1.21,
statements because
LOAD DATA
triggers, depending on
and an
AFTER UPDATE
Section 13.6.1,
or
DESCRIBE
SHOW
can
UPDATE
statements
BEFORE
trigger.
"BEGIN ...
Section E.1,
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers