> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# create_* 会话设置

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

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["版本", "默认值", "注释"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        版本历史
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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](/zh/reference/system-tables/settings) 中查看，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<h2 id="create_if_not_exists">
  create\_if\_not\_exists
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.9"},{"label": "0"},{"label": "新设置。"}]}]} />

默认对 `CREATE` 语句启用 `IF NOT EXISTS`。如果指定了此设置或 `IF NOT EXISTS`，且具有给定名称的表已存在，则不会抛出异常。

<h2 id="create_index_ignore_unique">
  create\_index\_ignore\_unique
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

忽略 CREATE UNIQUE INDEX 中的 UNIQUE 关键字。此设置用于 SQL 兼容性测试。

<h2 id="create_replicated_merge_tree_fault_injection_probability">
  create\_replicated\_merge\_tree\_fault\_injection\_probability
</h2>

<SettingsInfoBlock type="Float" default_value="0" />

在 ZooKeeper 中创建 metadata 后，创建表期间发生故障注入的概率

<h2 id="create_table_empty_primary_key_by_default">
  create\_table\_empty\_primary\_key\_by\_default
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.11"},{"label": "1"},{"label": "易用性更佳"}]}]} />

允许在未指定 ORDER BY 和 PRIMARY KEY 的情况下创建主键为空的 \*MergeTree 表

<h2 id="create_token_default_ttl_seconds">
  create\_token\_default\_ttl\_seconds
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.9"},{"label": "1800"},{"label": "新增设置，用于为通过 `CREATE TOKEN` 创建且未显式指定 `VALID UNTIL` 或 `VALID FOR` 子句的标记设置有效期。该语句为新增功能，因此没有可恢复的早期行为；先前值即默认值本身：与较早版本的 `兼容性` 不得导致标记变为永不过期。"}]}]} />

通过 [`CREATE TOKEN`](/zh/reference/statements/create/token) 创建且未指定自身 `VALID UNTIL` 或 `VALID FOR` 子句的标记的有效期，单位为秒。默认值为 30 分钟，因此未要求延长有效期的标记有效期较短。

可能的值：

* 正整数 — 标记将在创建后经过相应秒数后过期。
* 0 — 未指定显式子句的标记永不过期。

这仅是默认值。查询中显式指定的 `VALID UNTIL` 或 `VALID FOR` 子句始终优先，包括 `VALID UNTIL 'infinity'`；它会创建一个无论此设置为何都永不过期的标记。
