

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

# 查詢還原的 Amazon Glacier 物件
<a name="querying-glacier"></a>

您可以使用 Athena 查詢從 Amazon Glacier Flexible Retrieval (舊稱 Glacier) 和 Amazon Glacier Deep Archive [Amazon S3 儲存類別](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-glacier)中還原的物件。您必須基於每個資料表啟用此功能。如果您在執行查詢之前未在資料表上啟用此功能，Athena 會在查詢執行期略過資料表的所有 Amazon Glacier Flexible Retrieval 和 Amazon Glacier Deep Archive 物件。

## 考量事項與限制
<a name="querying-glacier-considerations-and-limitations"></a>
+  只有 Athena 引擎版本 3 才支援查詢還原的 Amazon Glacier 物件。
+  此功能僅支援 Apache Hive 資料表。
+  在查詢資料之前，您必須先還原物件；Athena 不會為您還原物件。

## 設定資料表，以使用還原的物件
<a name="querying-glacier-configuring-a-table-to-use-restored-objects"></a>

 若要將 Athena 資料表設定為在查詢中包含還原的物件，您必須將其 `read_restored_glacier_objects` 資料表屬性設定為 `true`。若要這樣做，您可以使用 Athena 查詢編輯器或 AWS Glue 主控台。您也可以使用 [AWS Glue CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/glue/update-table.html)、[AWS Glue API](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-UpdateTable) 或 [AWS Glue SDK](https://docs.aws.amazon.com/glue/latest/dg/sdk-general-information-section.html)。

### 使用 Athena 查詢編輯器
<a name="querying-glacier-using-the-athena-query-editor"></a>

 在 Athena 中，您可以使用 [ALTER TABLE SET TBLPROPERTIES](alter-table-set-tblproperties.md) 命令來設定資料表屬性，如下列範例所示。

```
ALTER TABLE table_name SET TBLPROPERTIES ('read_restored_glacier_objects' = 'true')
```

### 使用 AWS Glue 主控台
<a name="querying-glacier-using-the-aws-glue-console"></a>

 在 AWS Glue 主控台中，執行下列步驟來新增`read_restored_glacier_objects`資料表屬性。

**在 AWS Glue 主控台中設定資料表屬性**

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

1. 執行以下任意一項：
   + 選擇**移至資料目錄**。
   + 在導覽窗格中，選擇**資料目錄資料表**。

1. 在**資料表**頁面的資料表清單中，選擇您要編輯之資料表的連結。

1. 選擇 **Actions** (動作)、**Edit table** (編輯資料表)。

1. 在**編輯資料表**頁面的**資料表屬性**區段中，新增下列鍵值對。
   + 對於 **Key** (索引鍵)，新增 `read_restored_glacier_objects`。
   + 針對**數值**，輸入 `true`。

1. 選擇**儲存**。

### 使用 AWS CLI
<a name="querying-glacier-using-the-aws-cli"></a>

 在 中 AWS CLI，您可以使用 AWS Glue [update-table](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/glue/update-table.html) 命令及其`--table-input`引數來重新定義資料表，並在 中新增 `read_restored_glacier_objects` 屬性。在 `--table-input` 引數中，使用 `Parameters` 結構來指定 `read_restored_glacier_objects` 屬性和 `true` 的值。請注意，`--table-input` 的引數不得有空格，且必須使用反斜線來逸出雙引號。在以下範例中，使用您資料庫和資料表的名稱取代 {{my\_database}} 和 {{my\_table}}。

```
aws glue update-table \
   --database-name {{my_database}} \
   --table-input={\"Name\":\"{{my_table}}\",\"Parameters\":{\"read_restored_glacier_objects\":\"true\"}}
```

**重要**  
 AWS Glue `update-table` 命令會以覆寫模式運作，這表示它會以 `table-input` 參數指定的新定義取代現有的資料表定義。因此，在新增 `read_restored_glacier_objects` 屬性時，請務必也在 `table-input` 參數中指定您想要在資料表中顯示的所有欄位。