> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# default_* 会话设置

> default_* 生成分组中的 ClickHouse 会话设置。

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中查看，并由 [源文件](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="default_materialized_view_sql_security">
  ## default\_materialized\_view\_sql\_security
</div>

<SettingsInfoBlock type="SQLSecurityType" default_value="DEFINER" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.2"},{"label": "DEFINER"},{"label": "允许在创建 materialized view 时为 SQL SECURITY 选项设置默认值"}]}]} />

允许在创建 materialized view 时为 SQL SECURITY 选项设置默认值。[更多有关 SQL SECURITY 的信息](/docs/zh/reference/statements/create/view#sql_security)。

默认值为 `DEFINER`。

<div id="default_max_bytes_in_join">
  ## default\_max\_bytes\_in\_join
</div>

<SettingsInfoBlock type="UInt64" default_value="1000000000" />

当需要此限制但未设置 `max_bytes_in_join` 时，右侧表的最大大小。

<div id="default_normal_view_sql_security">
  ## default\_normal\_view\_sql\_security
</div>

<SettingsInfoBlock type="SQLSecurityType" default_value="INVOKER" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.2"},{"label": "INVOKER"},{"label": "允许在创建普通视图时设置默认的 `SQL SECURITY` 选项"}]}]} />

允许在创建普通视图时设置默认的 `SQL SECURITY` 选项。[了解更多 SQL security](/docs/zh/reference/statements/create/view#sql_security)。

默认值为 `INVOKER`。

<div id="default_table_engine">
  ## default\_table\_engine
</div>

<SettingsInfoBlock type="DefaultTableEngine" default_value="MergeTree" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "MergeTree"},{"label": "为提升易用性，将默认表引擎设为 MergeTree"}]}]} />

在 `CREATE` 语句中未设置 `ENGINE` 时使用的默认表引擎。

可能的值：

* 表示任意有效表引擎名称的字符串

Cloud 默认值：`SharedMergeTree`。

**示例**

查询：

```sql theme={null}
SET default_table_engine = 'Log';

SELECT name, value, changed FROM system.settings WHERE name = 'default_table_engine';
```

结果：

```response theme={null}
┌─name─────────────────┬─value─┬─changed─┐
│ default_table_engine │ Log   │       1 │
└──────────────────────┴───────┴─────────┘
```

在本示例中，任何未指定 `Engine` 的新表都会使用 `Log` 表引擎：

查询：

```sql theme={null}
CREATE TABLE my_table (
    x UInt32,
    y UInt32
);

SHOW CREATE TABLE my_table;
```

结果：

```response theme={null}
┌─statement────────────────────────────────────────────────────────────────┐
│ CREATE TABLE default.my_table
(
    `x` UInt32,
    `y` UInt32
)
ENGINE = Log
└──────────────────────────────────────────────────────────────────────────┘
```

<div id="default_temporary_table_engine">
  ## default\_temporary\_table\_engine
</div>

<SettingsInfoBlock type="DefaultTableEngine" default_value="Memory" />

与 [default\_table\_engine](/docs/zh/reference/settings/session-settings/default#default_table_engine) 相同，只是适用于临时表。

在此示例中，任何未指定 `Engine` 的新临时表都将使用 `Log` 表引擎：

查询：

```sql theme={null}
SET default_temporary_table_engine = 'Log';

CREATE TEMPORARY TABLE my_table (
    x UInt32,
    y UInt32
);

SHOW CREATE TEMPORARY TABLE my_table;
```

结果：

```response theme={null}
┌─statement────────────────────────────────────────────────────────────────┐
│ CREATE TEMPORARY TABLE default.my_table
(
    `x` UInt32,
    `y` UInt32
)
ENGINE = Log
└──────────────────────────────────────────────────────────────────────────┘
```

<div id="default_view_definer">
  ## default\_view\_definer
</div>

<SettingsInfoBlock type="String" default_value="CURRENT_USER" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.2"},{"label": "CURRENT_USER"},{"label": "可在创建视图时设置默认的 `DEFINER` 选项"}]}]} />

可在创建视图时设置默认的 `DEFINER` 选项。[关于 SQL security 的更多信息](/docs/zh/reference/statements/create/view#sql_security)。

默认值为 `CURRENT_USER`。
