MySQL: what does @@ mean?

mysql

Solution

`@@` - System Variable

`@@` is used for system variables. Using different suffix with `@@`, you can get either session or global value of the system variable.

When you refer to a system variable in an expression as `@@var_name` (that is, when you do not specify `@@global.` or `@@session.`), MySQL returns the session value if it exists and the global value otherwise. (This differs from `SET @@var_name = value`, which always refers to the session value.)

`@` - User-Defined Variable

While `@` is used for user-defined variables.

More Details

For more detailes read the following section from the official MySQL Reference Manual:

- SET Statements

Problem

I am reading the MySQL documentation on this page: http://dev.mysql.com/doc/refman/5.1/en/set-statement.html It often uses "@@", but does not define what "@@" means. Another example is in variable names: ``` mysql> select @@hostname; +------------+ | @@hostname | +------------+ | server1 | +------------+ 1 row in set (0.00 sec) mysql> select @hostname; +-----------+ | @hostname | +-----------+ | NULL | +-----------+ 1 row in set (0.00 sec) ``` What is @ vs @@?

Original source