ALTER SETTINGS PROFILE
Changes settings profiles.
Syntax:
ON CLUSTER clause allows altering settings profiles on a cluster, see Distributed DDL.
Replacing vs. modifying settings
ALTER SETTINGS PROFILE supports two different ways of changing the settings and the parent (inherited) profiles of a profile. They behave very differently, so it is important to pick the right one.
Replacing form: bare SETTINGS / INHERIT
A bare SETTINGS clause (without ADD, MODIFY or DROP) replaces the entire settings list and all parent profiles of the profile with exactly what you list. Anything previously present but not listed is silently dropped — there is no warning.
Because the bare SETTINGS form is a full replace, using it to "override one setting" on top of a populated base profile will drop every other setting (and every parent profile) on that profile. If you only want to change a single setting while keeping the rest, use the incremental MODIFY/ADD/DROP form described below.
This is the same behavior as SETTINGS in CREATE SETTINGS PROFILE: the clause defines the complete settings list.
Incremental form: ADD / MODIFY / DROP
The ADD, MODIFY and DROP keywords change individual entries while leaving everything else on the profile untouched:
ADD SETTINGS variable = value [constraints]— adds a setting that is not yet present.MODIFY SETTINGS variable = value [constraints]— replaces a single setting's entry. The whole entry (value and constraints) is overwritten, so re-specifyMIN/MAX/READONLY/etc. if you want to keep them.DROP SETTINGS variable [,...]— removes the listed settings.ADD PROFILES 'profile_name' [,...]/DROP PROFILES 'profile_name' [,...]— add or remove parent (inherited) profiles.DROP ALL SETTINGS/DROP ALL PROFILES— remove all settings or all parent profiles.
Several of these clauses can be combined in a single statement, for example DROP SETTINGS a ADD SETTINGS b = 1.
Examples
Override a single setting while preserving the rest of a populated profile:
Add a new constrained setting and drop another one:
Manage parent profiles incrementally:
Always verify the result with SHOW CREATE SETTINGS PROFILE:
Incremental vs full replacement
A bare SETTINGS clause removes all existing settings and all inherited (parent) profiles from the profile before applying the new ones.
To change a single setting while keeping the rest, use ADD SETTINGS or MODIFY SETTINGS (see examples below).
ADD vs MODIFY
Both ADD SETTINGS and MODIFY SETTINGS preserve the other settings in the profile, but they treat an existing entry for the same setting differently:
ADD SETTINGS variable = value ...first drops any existing entry forvariableand then inserts the new one. It therefore replaces the value together with all constraints of that setting. Any previously definedMIN,MAX, or writability (READONLY/WRITABLE/CONST/CHANGEABLE_IN_READONLY) forvariablethat you do not repeat is discarded.MODIFY SETTINGS variable = value ...merges field by field: it overrides only the fields you actually specify (the value, orMIN, orMAX, or the writability) and keeps the other fields of that setting as they were.
In short, use MODIFY SETTINGS when you only want to tweak one aspect of a setting (e.g. just the value, while keeping an existing MAX); use ADD SETTINGS when you want to redefine a setting from scratch.
Examples
Create a profile to use in the examples below:
MODIFY SETTINGS
Add or change a single setting while keeping the others:
Because MODIFY merges field by field, changing only the value of a setting keeps its existing constraints:
ADD SETTINGS
Add a setting (also keeping the others), redefining it completely if it already exists:
Unlike MODIFY, re-running ADD with only a value drops the previously defined constraints for that setting:
DROP SETTINGS
Remove one or more named settings:
Remove all settings at once:
Working with inherited profiles
Add or remove parent (inherited) profiles without affecting the profile's own settings: