Global variables can be classified based on their scope: session global variables and database global variables. These categories determine how the variable's value is accessed and managed.
Session Global Variables
Session global variables are uniquely associated with each session. This means that each user or application instance connected to the database will have its own, independent value for the variable.
- User-defined session global variables: These are created and managed by users within the session. Their values persist only for the duration of that session.
- Built-in session global variables: These are predefined by the database system and provide information about the current session, such as the user ID or connection details.
Database Global Variables
These variables, although the provided reference doesn't explicitly define them, are global across the entire database instance. A single value is available to all sessions. Modifications to the value are immediately visible to all connected users. They are generally less common and require careful consideration due to their potential for conflicts and performance implications.
In summary, global variables can be categorized primarily by the scope of their values - either specific to a user session or encompassing the entire database.