# 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`](https://coordinatordb.com/docs/reference/system-tables/settings) or [`SHOW SETTINGS`](https://coordinatordb.com/docs/reference/statements/show) to see the effective values.

## Syntax

```text
SET setting_name = value
```

## Supported names

* `log_queries`
* `log_queries_min_query_duration_ms`
* `max_execution_time`
* `max_memory_usage`
* `max_result_rows`
* `max_response_bytes`
* `max_threads`

The four connection/header settings use `PRAGMA` or validated `system.settings` writes instead. Consult the [database settings reference](https://coordinatordb.com/docs/reference/settings/session-settings) for types, units and defaults.

## Example

### Enabling query logging

```sql
SET log_queries = 1;
```

```sql
SELECT name, value
FROM system.settings
WHERE name = 'log_queries'
FORMAT csv;
```

```text
"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](https://coordinatordb.com/docs/reference/settings/formats) for those statement options.
