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

> S3 数据库引擎将亚马逊 S3 及兼容对象存储中的对象以只读表的形式暴露出来。

# S3

`S3` 数据库引擎将亚马逊 S3 及兼容 S3 的对象存储中的对象以只读表的形式呈现。表名会通过 [`s3`](/zh/reference/functions/table-functions/s3) 表函数解析为对象 URL。

## 创建数据库

```sql theme={null}
CREATE DATABASE s3_data
ENGINE = S3([url[, NOSIGN | access_key_id, secret_access_key]]);
```

该 engine 也可以接受一个 named collection。支持的配置 keys 有 `url`、`access_key_id`、`secret_access_key`、`no_sign_request` 和 `use_environment_credentials`。

## Usage

指定 base URL 后，表名即为相对于该 URL 的对象路径：

```sql theme={null}
CREATE DATABASE s3_data
ENGINE = S3('https://bucket.s3.amazonaws.com/data/', 'NOSIGN');

SELECT * FROM s3_data.`events.parquet`;
```

若未设置 base URL，请使用完整的对象 URL 作为表名。schema 和 format 的推断方式与 `s3` 表函数相同。该数据库本身不持有任何表定义，也不支持表的 DDL 或写入操作。

## Access control

S3 URL 会经由服务器的远程主机过滤器进行校验。无论 [`table_engines_require_grant`](/zh/reference/settings/server-settings/settings/other#table_engines_require_grant) 如何设置，创建该数据库都需要在 `S3` 上具备 `READ` 和 `WRITE` 的 source 授权，例如：

```sql theme={null}
GRANT READ, WRITE ON S3 TO user_name;
```

有关版本和兼容性详情，请参阅 [`SOURCES` 特权](/zh/reference/statements/grant#sources)。

## 另请参阅

* [`s3` 表函数](/zh/reference/functions/table-functions/s3)
* [在 ClickHouse 中使用 S3](/zh/integrations/connectors/data-ingestion/AWS/integrating-s3-with-clickhouse)
* [Filesystem 数据库引擎](/zh/reference/engines/database-engines/filesystem)
* [HDFS 数据库引擎](/zh/reference/engines/database-engines/hdfs)
