-
Notifications
You must be signed in to change notification settings - Fork 476
added enable and disable trigger to alter table #23217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
peachdawnleach
wants to merge
2
commits into
main
Choose a base branch
from
20260423-doc-16053-enable-disable-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,9 +51,11 @@ Subcommand | Description | Can combine with other subcommands? | |||||||||||||||||||||||||
| [`ALTER PRIMARY KEY`](#alter-primary-key) | Change the [primary key]({% link {{ page.version.version }}/primary-key.md %}) of a table. | Yes | ||||||||||||||||||||||||||
| [`CONFIGURE ZONE`](#configure-zone) | [Replication Controls]({% link {{ page.version.version }}/configure-replication-zones.md %}) for a table. | No | ||||||||||||||||||||||||||
| [`DISABLE ROW LEVEL SECURITY`](#disable-row-level-security) | Disable [row-level security]({% link {{ page.version.version }}/row-level-security.md %}) for a table. | Yes | ||||||||||||||||||||||||||
| [`DISABLE TRIGGER`](#disable-trigger) | Disable a [trigger]({% link {{ page.version.version }}/triggers.md %}) for a table. | Yes | ||||||||||||||||||||||||||
| [`DROP COLUMN`](#drop-column) | Remove columns from tables. | Yes | ||||||||||||||||||||||||||
| [`DROP CONSTRAINT`](#drop-constraint) | Remove constraints from columns. | Yes | ||||||||||||||||||||||||||
| [`ENABLE ROW LEVEL SECURITY`](#enable-row-level-security) | Enable [row-level security]({% link {{ page.version.version }}/row-level-security.md %}) for a table. | Yes | ||||||||||||||||||||||||||
| [`ENABLE TRIGGER`](#enable-trigger) | Enable a [trigger]({% link {{ page.version.version }}/triggers.md %}) for a table. | Yes | ||||||||||||||||||||||||||
| [`EXPERIMENTAL_AUDIT`](#experimental_audit) | Enable per-table audit logs, for security purposes. | Yes | ||||||||||||||||||||||||||
| [`FORCE / NO FORCE ROW LEVEL SECURITY`](#force-row-level-security) | Force the table owner to be subject to [row-level security]({% link {{ page.version.version }}/row-level-security.md %}) policies defined on a table. | Yes | ||||||||||||||||||||||||||
| [`OWNER TO`](#owner-to) | Change the owner of the table. | No | ||||||||||||||||||||||||||
|
|
@@ -501,6 +503,18 @@ This statement disables [Row-level security]({% link {{ page.version.version }}/ | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| For examples, refer to [Disable row-level security](#disable-row-level-security). | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### `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. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| For examples, refer to [Disable a trigger](#disable-a-trigger). | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Required privileges | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| The user must be a member of the [`admin`]({% link {{ page.version.version }}/security-reference/authorization.md %}#roles) or [owner]({% link {{ page.version.version }}/security-reference/authorization.md %}#object-ownership) roles. | ||||||||||||||||||||||||||
|
|
@@ -3415,6 +3429,48 @@ ALTER TABLE orders NO FORCE ROW LEVEL SECURITY; | |||||||||||||||||||||||||
| Users with the `BYPASSRLS` [role option]({% link {{ page.version.version }}/security-reference/authorization.md %}#role-options) can still bypass RLS even when `ALTER TABLE ... FORCE ROW LEVEL SECURITY` is enabled. | ||||||||||||||||||||||||||
| {{site.data.alerts.end}} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### Enable a trigger | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| To enable a [trigger]({% link {{ page.version.version }}/triggers.md %}) associated with a table, use the following statement: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> ENABLE TRIGGER <trigger_name>; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
Comment on lines
+3435
to
+3439
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realized this was implied throughout the updates but never explicit. One option for your consideration. |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| To enable all triggers associated with a table, use either of the following statements: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> ENABLE TRIGGER ALL; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> ENABLE TRIGGER USER; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### Disable a trigger | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| To disable a [trigger]({% link {{ page.version.version }}/triggers.md %}) associated with a table, use the following statement: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> DISABLE TRIGGER <trigger_name>; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| To disable all triggers associated with a table, use either of the following statements: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> DISABLE TRIGGER ALL; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| {% include_cached copy-clipboard.html %} | ||||||||||||||||||||||||||
| ~~~ sql | ||||||||||||||||||||||||||
| ALTER TABLE <table_name> DISABLE TRIGGER USER; | ||||||||||||||||||||||||||
| ~~~ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## See also | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - [Multi-Region Capabilities Overview]({% link {{ page.version.version }}/multiregion-overview.md %}) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think readers will wonder what the difference is between
DISABLE TRIGGER ALLandDISABLE TRIGGER USER.I found the answer from the implementation PR (#161924).
In case it helps (maybe you were already aware!) in CockroachDB,
ALLandUSERdo 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?
I would probably include this again under
Enable a trigger, so that users who end up there first will also see it.