added enable and disable trigger to alter table#23217
added enable and disable trigger to alter table#23217peachdawnleach wants to merge 2 commits intomainfrom
Conversation
✅ Deploy Preview for cockroachdb-api-docs canceled.
|
✅ Deploy Preview for cockroachdb-interactivetutorials-docs canceled.
|
Files changed: |
✅ Netlify Preview
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Netlify Preview
To edit notification comments on pull requests, go to your Netlify project configuration. |
rafiss
left a comment
There was a problem hiding this comment.
lgtm! thanks for adding this
mikeCRL
left a comment
There was a problem hiding this comment.
Looks good. A couple suggestions.
| ### `ENABLE TRIGGER` | ||
|
|
||
| This statement enables a [trigger]({% link {{ page.version.version }}/triggers.md %}) associated with a table. When a trigger is enabled for a table, it activates if its triggering event occurs on the table. Use `ENABLE TRIGGER ALL` or `ENABLE TRIGGER USER` to enable all triggers associated with a table. | ||
|
|
||
| For examples, refer to [Enable a trigger](#enable-a-trigger). | ||
|
|
||
| ### `DISABLE TRIGGER` | ||
|
|
||
| This statement disables a [trigger]({% link {{ page.version.version }}/triggers.md %}) associated with a table. When a trigger is disabled for a table, it does not activate even if its triggering event occurs on the table. Use `DISABLE TRIGGER ALL` or `DISABLE TRIGGER USER` to disable all triggers associated with a table. |
There was a problem hiding this comment.
I think readers will wonder what the difference is between DISABLE TRIGGER ALL and DISABLE TRIGGER USER.
I found the answer from the implementation PR (#161924).
In case it helps (maybe you were already aware!) in CockroachDB, ALL and USER do the exact same thing. These are both present for compatibility with PostgreSQL, which distinguishes between system and user triggers. In CRDB, both affect all triggers on the table, since we don't have system triggers.
Consider a callout like this?
ALLandUSERare both available for compatibility with PostgreSQL syntax, though in CockroachDB they behave identically. (CockroachDB does not have system triggers.) Both keywords will enable/disable all triggers associated with the table.
I would probably include this again under Enable a trigger, so that users who end up there first will also see it.
|
|
||
| {% include_cached copy-clipboard.html %} | ||
| ~~~ sql | ||
| ALTER TABLE <table_name> ENABLE TRIGGER <trigger_name>; | ||
| ~~~ |
There was a problem hiding this comment.
| {% include_cached copy-clipboard.html %} | |
| ~~~ sql | |
| ALTER TABLE <table_name> ENABLE TRIGGER <trigger_name>; | |
| ~~~ | |
| {% include_cached copy-clipboard.html %} | |
| ~~~ sql | |
| ALTER TABLE <table_name> ENABLE TRIGGER <trigger_name>; | |
| ~~~ | |
| This requires an existing trigger. For information on creating a trigger, refer to [Triggers]({% link {{ page.version.version }}/triggers.md %}). |
There was a problem hiding this comment.
Realized this was implied throughout the updates but never explicit. One option for your consideration.
Fixes: DOC-16053 and DOC-11412
Adds
ENABLE TRIGGERandDISABLE TRIGGERtoALTER TABLE