Documentation Source Text

Check-in [998c5310eb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the CREATE TRIGGER documentation to acknowledge the fact that columns in the UPDATE OF syntax of CREATE TRIGGER need not exist in the table, and that the trigger only fires if one of the columns named in the UPDATE OF clause appear on the left-hand side of one of the terms in the SET clause of the UPDATE statement.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 998c5310ebb9d6e181f866f60883d512dff66b16a177b9fce170e14a93fde18c
User & Date: drh 2019-10-21 14:57:02.414
Context
2019-10-22
13:26
Fix a typo on the whentouse.html page. (check-in: 8b5ba0e2b1 user: drh tags: trunk)
2019-10-21
14:57
Update the CREATE TRIGGER documentation to acknowledge the fact that columns in the UPDATE OF syntax of CREATE TRIGGER need not exist in the table, and that the trigger only fires if one of the columns named in the UPDATE OF clause appear on the left-hand side of one of the terms in the SET clause of the UPDATE statement. (check-in: 998c5310eb user: drh tags: trunk)
2019-10-18
02:16
Fix a typo in the "quirks.html" document. (check-in: 7dce3c2f8a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to pages/lang.in.
1375
1376
1377
1378
1379
1380
1381

1382




1383
1384


1385





1386
1387
1388
1389
1390
1391
1392
</tcl>

<p>^The CREATE TRIGGER statement is used to add triggers to the 
database schema. ^Triggers are database operations 
that are automatically performed when a specified database event
occurs.  </p>


<p>^A trigger may be specified to fire whenever a [DELETE], [INSERT],




or [UPDATE] of a
particular database table occurs, or whenever an [UPDATE] occurs on


on one or more specified columns of a table.</p>






<p>^At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
STATEMENT triggers. ^Hence explicitly specifying FOR EACH ROW is optional.
^FOR EACH ROW implies that the SQL statements specified in the trigger
may be executed (depending on the WHEN clause) for each database row being
inserted, updated or deleted by the statement causing the trigger to fire.</p>








>
|
>
>
>
>
|
|
>
>
|
>
>
>
>
>







1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
</tcl>

<p>^The CREATE TRIGGER statement is used to add triggers to the 
database schema. ^Triggers are database operations 
that are automatically performed when a specified database event
occurs.  </p>

<p>^Each trigger must specify that it will fire for one of
the following operations: [DELETE], [INSERT], [UPDATE].
The trigger fires once for each row that is deleted, inserted,
or updated.  If the "UPDATE OF <yyterm>column-name</yyterm>"
syntax is used, then the trigger will only fire if
<yyterm>column-name</yyterm> appears on the left-hand side of
one of the terms in the SET clause of the [UPDATE] statement.</p>

<p>Due to an historical oversight, columns named in the "UPDATE OF"
clause do not actually have to exist in the table being updated.
Unrecognized column names are silently ignored.
It would be more helpful if SQLite would fail the CREATE TRIGGER
statement if any of the names in the "UPDATE OF" clause are not
columns in the table.  However, as this problem was discovered
many years after SQLite was widely deployed, we have resisted
fixing the problem for fear of breaking legacy applications.</p>

<p>^At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH
STATEMENT triggers. ^Hence explicitly specifying FOR EACH ROW is optional.
^FOR EACH ROW implies that the SQL statements specified in the trigger
may be executed (depending on the WHEN clause) for each database row being
inserted, updated or deleted by the statement causing the trigger to fire.</p>