

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

# 將資料庫和資料表新增至 S3 Tables 目錄
<a name="create-databases-tables-s3-catalog"></a>

請確定您擁有必要的許可，以列出和建立 區域中 Data Catalog 中的目錄、資料庫和資料表。確保已在 AWS 您的帳戶和區域中啟用 S3 Tables 整合。

## 將資料庫新增至 S3 Tables 目錄
<a name="add-database-s3-tables-catalog"></a>

### 新增資料庫 （主控台）
<a name="add-database-s3-tables-console"></a>

1. 在 https：//[https://console.aws.amazon.com/glue/home](https://console.aws.amazon.com/glue/home) 開啟 AWS Glue 主控台。

1. 在左側的導覽窗格中，選擇**資料庫**。

1. 選擇**新增資料庫**。

1. **在 S3 Tables 聯合目錄中選擇 Glue 資料庫**。

1. 輸入資料庫的唯一名稱。

1. 選取映射至 S3 Tables 中資料表儲存貯體的目標目錄。

1. 選擇 **Create Database (建立資料庫)**。

### 新增資料庫 (AWS CLI)
<a name="add-database-s3-tables-cli"></a>

```
aws glue create-database \
  --region {{region}} \
  --catalog-id "{{account-id}}:s3tablescatalog/{{my-catalog}}" \
  --database-input '{"Name": "{{my-database}}"}'
```

## 將資料表新增至 S3 Tables 目錄
<a name="add-table-s3-tables-catalog"></a>

### 新增資料表 （主控台）
<a name="add-table-s3-tables-console"></a>

1. 在 https：//[https://console.aws.amazon.com/glue/home](https://console.aws.amazon.com/glue/home) 開啟 AWS Glue 主控台。

1. 在左側導覽窗格中，選擇 **Tables (資料表)**。

1. 在目錄下拉式清單中選取適當的 S3 Tables 目錄。

1. 選擇**新增資料表**。

1. 輸入資料表的唯一名稱。

1. 在目錄下拉式清單中確認已選取正確的 S3 Tables 目錄。

1. 在資料庫下拉式清單中選取資料庫。

1. 透過輸入 JSON 或個別新增每個資料欄來輸入資料表結構描述。

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

### 新增資料表 (AWS CLI)
<a name="add-table-s3-tables-cli"></a>

```
aws glue create-table \
  --region {{region}} \
  --catalog-id "{{account-id}}:s3tablescatalog/{{my-catalog}}" \
  --database-name "{{my-database}}" \
  --table-input '{
    "Name": "{{my-table}}",
    "Parameters": {
      "classification": "",
      "format": "ICEBERG"
    },
    "StorageDescriptor": {
      "Columns": [
        {"Name": "id", "Type": "int", "Parameters": {}},
        {"Name": "val", "Type": "string", "Parameters": {}}
      ]
    }
  }'
```