> ## 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.

> HDFS 数据库引擎将 HDFS 中的文件以只读表的形式呈现。

# HDFS

`HDFS` 数据库引擎将 HDFS 中的文件以只读表的形式暴露出来。表名通过 [`hdfs`](/zh/reference/functions/table-functions/hdfs) 表函数进行解析。

## 创建数据库

```sql theme={null}
CREATE DATABASE hdfs_data
ENGINE = HDFS([hdfs_host_and_root_path]);
```

`hdfs_host_and_root_path` 为可选项，用于设置 HDFS 基础 URL。设置该项后，表名即为相对于该 URL 的路径；若未设置，表名必须是完整的 `hdfs://` URL。

## 用量

```sql theme={null}
CREATE DATABASE hdfs_data
ENGINE = HDFS('hdfs://namenode:9000/data');

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

schema 与 format 的推断方式与 `hdfs` 表函数相同。该数据库不持有任何表定义，也不支持表的 DDL 或写入操作。

## 访问控制

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

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

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

## 另请参阅

* [`hdfs` 表函数](/zh/reference/functions/table-functions/hdfs)
* [Filesystem 数据库引擎](/zh/reference/engines/database-engines/filesystem)
* [S3 数据库引擎](/zh/reference/engines/database-engines/s3)
