alter_algorithm
This page is part of MariaDB's Enterprise Documentation.
The parent of this page is: System Variables for MariaDB Enterprise Server
Topics on this page:
Overview
- In 10.6 ES, 10.6 CS, 10.5 ES, 10.5 CS, 10.4 ES, 10.4 CS, 10.3 ES, 10.3 CS:
Configures the server to use specific algorithms for ALTER TABLE operations.
- In 10.2 ES, 10.2 CS:
Not present
See also: System Variables for MariaDB Enterprise Server 10.6, in 10.6 CS, in 10.5 ES, in 10.5 CS, in 10.4 ES, in 10.4 CS, in 10.3 ES, in 10.3 CS, in 10.2 ES, and in 10.2 CS
USAGE
The alter_algorithm
system variable can be set in a configuration file:
[mariadb]
alter_algorithm=INPLACE
The global value of the alter_algorithm
system variable can also be set dynamically at runtime by executing SET GLOBAL:
SET GLOBAL alter_algorithm='INPLACE';
The session value of the alter_algorithm
system variable can also be set dynamically at runtime by executing SET SESSION:
SET SESSION alter_algorithm='INPLACE';
When the alter_algorithm
system variable is set dynamically at runtime, its value will be reset the next time the server restarts. To make the value persist on restart, set it in a configuration file too.
DETAILS
This system variable can configure the server to use specific algorithms for ALTER TABLE operations:
Alter Algorithm | Description |
---|---|
DEFAULT | In this mode, the server uses the most efficient algorithm for a given operation. |
COPY | In this mode, the server will only use the |
INPLACE | In this mode, the server will only use the |
NOCOPY | In this mode, the server will only use the |
INSTANT | In this mode, the server will only use the |
PARAMETERS
Command-line | --alter_algorithm[={DEFAULT| |
Configuration file | Supported |
Dynamic | Yes |
Scope | Global, Session |
Data Type | ENUM (DEFAULT, COPY, INPLACE, NOCOPY, INSTANT) |
Default Value | DEFAULT |
PRIVILEGES
The alter_algorithm
system variable requires the SUPER
privilege to dynamically set its global value at runtime.
The alter_algorithm
system variable does not require any special privilege to dynamically set its session value at runtime.
EXAMPLES
Disambiguating Default Values
When you set the session value of the alter_algorithm
system variable, the value DEFAULT
has two different meanings, depending on whether the value is quoted.
Let's say that the value is quoted:
SET SESSION alter_algorithm='DEFAULT';
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
This sets the session value to the literal value of DEFAULT
, which tells the server to use the default alter algorithm for all ALTER TABLE operations.
Let's say that the value is not quoted:
SET SESSION alter_algorithm=DEFAULT;
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | INPLACE |
+-----------------+---------+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | INPLACE |
+-----------------+---------+
This sets the session value to the global value.
In contrast, when you set the global value of the alter_algorithm
system variable, the value DEFAULT
only has a single meaning:
SET GLOBAL alter_algorithm='DEFAULT';
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
SET GLOBAL alter_algorithm=DEFAULT;
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
Dynamically Resetting Global Value to Default
The global value of the alter_algorithm
system variable can be dynamically reset to the default value by setting it to DEFAULT
:
SET GLOBAL alter_algorithm='INPLACE';
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | INPLACE |
+-----------------+---------+
SET GLOBAL alter_algorithm=DEFAULT;
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
Resetting Session Value to Global Value
The session value of the alter_algorithm
system variable can be reset to the global value by setting it to DEFAULT
:
SET SESSION alter_algorithm='INPLACE';
SHOW GLOBAL VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | INPLACE |
+-----------------+---------+
SET SESSION alter_algorithm=DEFAULT;
SHOW SESSION VARIABLES LIKE 'alter_algorithm';
+-----------------+---------+
| Variable_name | Value |
+-----------------+---------+
| alter_algorithm | DEFAULT |
+-----------------+---------+
Invalid Value for Variable
If a user tries to set the alter_algorithm
system variable to an invalid value, then the operation will fail with the ER_WRONG_VALUE_FOR_VAR error code:
SET GLOBAL alter_algorithm=-1;
ERROR 1231 (42000): Variable 'alter_algorithm' can't be set to the value of '-1'
Invalid Type for Variable
If a user tries to set the alter_algorithm
system variable to an invalid argument, then the operation will fail with the ER_WRONG_TYPE_FOR_VAR error code:
SET GLOBAL alter_algorithm=1.0;
ERROR 1232 (42000): Incorrect argument type to variable 'alter_algorithm'
CHANGE HISTORY
Release Series | History |
---|---|
10.6 Enterprise |
|
10.6 Community |
|
10.5 Enterprise |
|
10.5 Community |
|
10.4 Enterprise |
|
10.4 Community |
|
10.3 Enterprise |
|
10.3 Community |
|
10.2 Enterprise |
|
10.2 Community |
|
EXTERNAL REFERENCES
Information specific to MariaDB SkySQL can be found on the alter_algorithm page in the SkySQL Documentation.