

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 S3 資料表目錄中建立資料庫和資料表
<a name="create-databases-tables-s3-catalog"></a>

 您可以建立資料庫來組織 Apache Iceberg 資料表，以及建立資料表來定義 S3 資料表目錄中資料的結構描述和位置。

## 建立資料庫 （主控台）
<a name="w2aac13c27c25b5b1"></a>

1.  在 https：//[https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/) 開啟 Lake Formation 主控台，並以資料湖管理員或資料庫建立者身分登入。

1. 在導覽窗格中，選擇 **Data Catalog** **下的資料庫**。

1. 選擇**建立資料庫**。

1.  在**建立資料庫**頁面上，選擇**資料庫**選項，然後輸入下列詳細資訊：
   + **名稱 **– 資料庫的唯一名稱
   + **資料目錄** – 選擇 S3 資料表目錄。資料庫將位於此目錄中。
   + **描述** –（選用） 新增描述和位置。
   + **新資料表的 IAM 存取控制** – 選擇性地選取僅對此資料庫中的新資料表使用 IAM 存取控制。如需此選項的相關資訊，請參閱[變更資料湖的預設設定](https://docs.aws.amazon.com/lake-formation/latest/dg/change-settings.html)一節。
   + 選擇**建立資料庫**。您可以查看在 S3 資料表目錄下建立的資料庫。

## 使用 建立資料庫 AWS CLI
<a name="w2aac13c27c25b5b3"></a>

下列 CLI 命令顯示如何在 S3 資料表目錄中建立資料庫。

```
aws glue create-database 
--region us-east-1 \
--catalog-id "123456789012:s3tablescatalog/test" \
--database-input \
 '{ "Name": "testglueclidbcreation" }'
```

## 建立資料表 (AWS 管理主控台)
<a name="w2aac13c27c25b5b5"></a>

 您可以使用 Lake Formation 主控台或 API，在 S3 資料表目錄中建立 Apache Iceberg AWS Glue `CreateTable`中繼資料表。

1. 開啟 Lake Formation 主控台，網址為 [https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/)：//`CreateTable`。

1. 在導覽窗格中，選擇 Data Catalog **下的資料表**。

1. 選擇 Create Table (建立資料表)。

1. 在**建立資料表**頁面上，輸入資料表詳細資訊：  
![\[S3 資料表目錄\]](http://docs.aws.amazon.com/zh_tw/lake-formation/latest/dg/images/s3-catalog-create-table.png)
   + **名稱 **– 輸入資料表的唯一名稱。
   + **目錄** – 選擇 S3 資料表目錄做為目錄。
   + **資料庫** – 選擇 S3 資料表目錄下的資料庫。
   +  **描述** – 輸入資料表的描述。
   + **結構描述** – 選擇新增資料欄以新增資料欄和資料欄的資料類型。可以選擇建立空白資料表，稍後再更新結構描述。Iceberg 可讓您在建立資料表之後改進結構描述和分區。可以使用 Athena 查詢來更新資料表結構描述，使用 Spark 查詢來更新分區。

1. 選擇**提交**。

## 建立資料表 (AWS CLI)
<a name="w2aac13c27c25b5b7"></a>

```
aws glue create-table \ 
--database-name "testglueclidbcreation" \ 
--catalog-id "123456789012:s3tablescatalog/test" \ 
--region us-east-1 \ 
--table-input \ 
'{ "Name": "testtablegluecli", "Parameters": { "format": "ICEBERG" }, "StorageDescriptor": { "Columns": [ {"Name": "x", "Type": "int", "Parameters": {"required": "true"}} ] } }'
```