SET
SET saves a database setting and applies it to connected clients before later requests. A database must be selected first.
Database management changes require autocommit and no active transactions in the selected database. Resource limits are sampled once per request, so a SET within a batch changes defaults for later requests.
Values are validated before they are persisted. Configured server XML ceilings still limit the effective setting; inspect system.settings or SHOW SETTINGS to see the effective values.
Syntax
SET setting_name = valueSupported names
log_querieslog_queries_min_query_duration_msmax_execution_timemax_memory_usagemax_result_rowsmax_response_bytesmax_threads
The four connection/header settings use PRAGMA or validated system.settings writes instead. Consult the database settings reference for types, units and defaults.
Example
Enabling query logging
SET log_queries = 1;SELECT name, value
FROM system.settings
WHERE name = 'log_queries'
FORMAT csv;"log_queries","1"SET and SETTINGS
SET persists a database setting. A statement SETTINGS clause configures data-format options for one statement and does not persist them. Format options such as csv_separator are not accepted as database SET names.
See format settings for those statement options.