•
and
LOCAL
@@local.
• If no modifier is present,
A
statement can contain multiple variable assignments, separated by commas. If you set several
SET
system variables, the most recent
variables that have no modifier specified.
Examples:
SET sort_buffer_size=10000;
SET @@local.sort_buffer_size=10000;
SET GLOBAL sort_buffer_size=1000000, SESSION sort_buffer_size=1000000;
SET @@sort_buffer_size=1000000;
SET @@global.sort_buffer_size=1000000, @@local.sort_buffer_size=1000000;
The
syntax for system variables is supported for compatibility with some other database
@@var_name
systems.
If you change a session system variable, the value remains in effect until your session ends or until you
change the variable to a different value. The change is not visible to other clients.
If you change a global system variable, the value is remembered and used for new connections until
the server restarts. (To make a global system variable setting permanent, you should set it in an option
file.) The change is visible to any client that accesses that global variable. However, the change affects
the corresponding session variable only for clients that connect after the change. The global variable
change does not affect the session variable for any client that is currently connected (not even that of
the client that issues the
To prevent incorrect usage, MySQL produces an error if you use
can only be used with
SET SESSION
global variable.
To set a
variable to the
SESSION
value, use the
DEFAULT
session value of
max_join_size
SET max_join_size=DEFAULT;
SET @@session.max_join_size=@@global.max_join_size;
Not all system variables can be set to DEFAULT. In such cases, use of
You can refer to the values of specific global or session system variables in expressions by using one
of the @@-modifiers. For example, you can retrieve values in a
SELECT @@global.sql_mode, @@session.sql_mode, @@sql_mode;
When you refer to a system variable in an expression as
specify
or @@session.), MySQL returns the session value if it exists and the global value
@@global.
otherwise. (This differs from
Note
Some variables displayed by
SELECT @@var_name
As a workaround in such cases, you can use
'var_name'.
Suffixes for specifying a value multiplier can be used when setting a variable at server startup, but not
to set the value with
SET
using an expression, which is not true when you set a variable at server startup. For example, the first
of the following lines is legal at server startup, but the second is not:
shell>
mysql --max_allowed_packet=16M
shell>
mysql --max_allowed_packet=16*1024*1024
Using System Variables
are synonyms for
SESSION
changes the session variable.
SET
or
GLOBAL
SESSION
statement).
SET GLOBAL
or if you do not specify
value or a
GLOBAL
keyword. For example, the following two statements are identical in setting the
[469]
to the global value:
SET @@var_name =
syntax; an
at runtime. On the other hand, with
508
and @@session..
modifier in the statement is used for following
SET GLOBAL
(or @@global.) when setting a
GLOBAL
value to the compiled-in MySQL default
GLOBAL
DEFAULT
SELECT
@@var_name
value, which always refers to the session value.)
may not be available using
SHOW VARIABLES
Unknown system variable
SHOW VARIABLES LIKE
you can assign a variable's value
SET
with a variable that
results in an error.
statement like this:
(that is, when you do not
occurs.
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers