SET Statements Examples: As demonstrated by those statements,  expr  can range from simple (a literal value) to more complex (the value returned by a scalar subquery). The Performance Schema  user_variables_by_thread  table contains information about user-defined variables. See Section 27.12.10, “Performance Schema User-Defined Variable Tables” . SET  applies to parameters and local variables in the context of the stored object within which they are defined. The following procedure uses the  increment  procedure parameter and  counter  local variable: The MySQL server maintains system variables that configure its operation. A system variable can have a global value that affects server operation as a whole, a session value that affects the current session, or both. Many system variables are dynamic and can be changed at runtime using the  SET  statement to affect operation of the current server instance.  SET  can also be used to persist certain system variables to the mysqld-auto.cnf  file in the data directory, to affect server operation for subsequent startups. If you change a session system variable, the value remains in effect within your session until you change the variable to a different value or the session ends. The change has no effect on other sessions. If you change a global system variable, the value is remembered and used to initialize the session value for new sessions until you change the variable to a different value or the server exits. The change is visible to any client that accesses the global value. However, the change affects the corresponding session value only for clients that connect after the change. The global variable change does not affect the session value for any current client sessions (not even the session within which the global value change occurs). To make a global system variable setting permanent so that it applies across server restarts, you can persist it to the  mysqld-auto.cnf  file in the data directory. It is also possible to make persistent configuration changes by manually modifying a  my.cnf  option file, but that is more cumbersome, and an error in a manually entered setting might not be discovered until much later.  SET  statements that persist system variables are more convenient and avoid the possibility of malformed settings because settings with syntax errors do not succeed and do not change server configuration. For more information about persisting system variables and the  mysqld-auto.cnf  file, see Section 5.1.9.3, “Persisted System Variables” . Setting or persisting a global system variable value always requires special privileges. Setting a session system variable value normally requires no special privileges and can be done by any user, although there are exceptions. For more information, see Section 5.1.9.1, “System Variable Privileges” . 2907 Note System Variable Assignment Parameter and Local Variable Assignment SET @name = 43; SET @total_tax = (SELECT SUM(tax) FROM taxable_transactions); CREATE PROCEDURE p(increment INT) BEGIN DECLARE counter INT DEFAULT 0; WHILE counter < 10 DO -- ... do work ... SET counter = counter + increment; END WHILE; END;