GLOBAL is a reserved SQL keyword that serves as a scope qualifier. In the SQL standard it appears in the construct CREATE GLOBAL TEMPORARY TABLE, which defines a temporary table whose definition is permanent in the catalog but whose data is private to each session. Many commercial databases adopt the same syntax. In MySQL and MariaDB, GLOBAL is also used with SET and SHOW to reference server-level system variables and status counters. Although GLOBAL never stands alone, understanding its meaning is critical for correctly handling temporary objects and configuration changes across sessions.Behavior by context:1. CREATE GLOBAL TEMPORARY TABLE - The table definition is stored in the schema. - Each session sees an empty copy of the table; rows disappear at session end (or optionally at transaction end in Oracle).2. SET GLOBAL system_variable = value - Changes the variable for all future sessions until the server restarts or another SET GLOBAL overrides it.3. SHOW GLOBAL STATUS / SHOW GLOBAL VARIABLES - Returns server-wide counters or configuration values.Caveats- GLOBAL does not make a temporary table share data across sessions; only the definition is global.- Setting GLOBAL variables may require SUPER or SYSTEM_VARIABLES_ADMIN privileges.- Some dialects (PostgreSQL, SQLite) reserve the word but do not implement GLOBAL-scoped temporary tables.- GLOBAL temporary tables cannot be indexed with non-temporary indexes in several systems.
table_name
(identifier) - Name of the temporary table to create.column_definition
(list) - Column names, types, and constraints.system_variable
(identifier) - Name of a server variable (e.g., max_connections).value
(expression) - New value assigned to the variable.LOCAL, TEMPORARY, CREATE TABLE, SESSION, SET, SHOW, SYSTEM VARIABLES
SQL:1999
GLOBAL temporary tables have a permanent definition and session-private data, while LOCAL temporary tables (supported in some systems) may have both definition and data tied to the current session only.
No. The change is effective immediately for new sessions and lasts until the server shuts down or another SET GLOBAL overrides it.
PostgreSQL reserves the word GLOBAL but does not implement GLOBAL TEMPORARY TABLE or GLOBAL variable scope. You must use CREATE TEMP TABLE instead.
Yes. In MySQL you need the SUPER or SYSTEM_VARIABLES_ADMIN privilege to modify most GLOBAL variables.