

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

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

# 使用 的 Athena 範例 AWS CLI
<a name="cli_2_athena_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 Athena 執行動作和實作常見案例。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `batch-get-named-query`
<a name="athena_BatchGetNamedQuery_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-get-named-query`。

**AWS CLI**  
**傳回多個查詢的相關資訊**  
下列 `batch-get-named-query` 範例會傳回具有指定 ID 之具名查詢的相關資訊。  

```
aws athena batch-get-named-query \
    --named-query-ids a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 a1b2c3d4-5678-90ab-cdef-EXAMPLE22222 a1b2c3d4-5678-90ab-cdef-EXAMPLE33333
```
輸出：  

```
{
    "NamedQueries": [
        {
            "Name": "Flights Select Query",
            "Description": "Sample query to get the top 10 airports with the most number of departures since 2000",
            "Database": "sampledb",
            "QueryString": "SELECT origin, count(*) AS total_departures\nFROM\nflights_parquet\nWHERE year >= '2000'\nGROUP BY origin\nORDER BY total_departures DESC\nLIMIT 10;",
            "NamedQueryId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "WorkGroup": "primary"
        },
        {
            "Name": "Load flights table partitions",
            "Description": "Sample query to load flights table partitions using MSCK REPAIR TABLE statement",
            "Database": "sampledb",
            "QueryString": "MSCK REPAIR TABLE flights_parquet;",
            "NamedQueryId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "WorkGroup": "primary"
        },
        {
            "Name": "CloudFront Select Query",
            "Description": "Sample query to view requests per operating system during a particular time frame",
            "Database": "sampledb",
            "QueryString": "SELECT os, COUNT(*) count FROM cloudfront_logs WHERE date BETWEEN date '2014-07-05' AND date '2014-08-05' GROUP BY os;",
            "NamedQueryId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
            "WorkGroup": "primary"
        }
    ],
    "UnprocessedNamedQueryIds": []
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchGetNamedQuery](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/batch-get-named-query.html)。

### `batch-get-query-execution`
<a name="athena_BatchGetQueryExecution_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-get-query-execution`。

**AWS CLI**  
**傳回一或多個查詢執行的相關資訊**  
下列 `batch-get-query-execution` 範例會傳回具有指定查詢 ID 之查詢的查詢執行資訊。  

```
aws athena batch-get-query-execution \
    --query-execution-ids a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 a1b2c3d4-5678-90ab-cdef-EXAMPLE22222
```
輸出：  

```
{
    "QueryExecutions": [
        {
            "QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "Query": "create database if not exists webdata",
            "StatementType": "DDL",
            "ResultConfiguration": {
                "OutputLocation": "s3://amzn-s3-demo-bucket/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111.txt"
            },
            "QueryExecutionContext": {},
            "Status": {
                "State": "SUCCEEDED",
                "SubmissionDateTime": 1593470720.592,
                "CompletionDateTime": 1593470720.902
            },
            "Statistics": {
                "EngineExecutionTimeInMillis": 232,
                "DataScannedInBytes": 0,
                "TotalExecutionTimeInMillis": 310,
            "ResultConfiguration": {

                "QueryQueueTimeInMillis": 50,
                "ServiceProcessingTimeInMillis": 28
            },
            "WorkGroup": "AthenaAdmin"
        },
        {
            "QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
            "Query": "select date, location, browser, uri, status from cloudfront_logs where method = 'GET' and status = 200 and location like 'SFO%' limit 10",
            "StatementType": "DML",
            "ResultConfiguration": {
                "OutputLocation": "s3://amzn-s3-demo-bucket/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222.csv"
            },
            "QueryExecutionContext": {
                "Database": "mydatabase",
                "Catalog": "awsdatacatalog"
            },
            "Status": {
                "State": "SUCCEEDED",
                "SubmissionDateTime": 1593469842.665,
                "CompletionDateTime": 1593469846.486
            },
            "Statistics": {
                "EngineExecutionTimeInMillis": 3600,
                "DataScannedInBytes": 203089,
                "TotalExecutionTimeInMillis": 3821,
                "QueryQueueTimeInMillis": 267,
                "QueryPlanningTimeInMillis": 1175
            },
            "WorkGroup": "AthenaAdmin"
        }
    ],
    "UnprocessedQueryExecutionIds": []
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchGetQueryExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/batch-get-query-execution.html)。

### `create-data-catalog`
<a name="athena_CreateDataCatalog_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-data-catalog`。

**AWS CLI**  
**建立資料目錄**  
下列 `create-data-catalog` 範例會建立 `dynamo_db_catalog` 資料目錄。  

```
aws athena create-data-catalog \
    --name dynamo_db_catalog \
    --type LAMBDA \
    --description "DynamoDB Catalog" \
    --parameters function=arn:aws:lambda:us-west-2:111122223333:function:dynamo_db_lambda
```
此命令不會產生輸出。若要查看結果，請使用 `aws athena get-data-catalog --name dynamo_db_catalog`。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[註冊目錄：create-data-catalog](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-registering-a-catalog)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateDataCatalog](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/create-data-catalog.html)。

### `create-named-query`
<a name="athena_CreateNamedQuery_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-named-query`。

**AWS CLI**  
**建立具名查詢**  
下列 `create-named-query` 範例在 `AthenaAdmin` 工作群組中建立已儲存的查詢，其中查詢 `flights_parquet` 資料表中是否有 2016 年 1 月從西雅圖到紐約的航班的出發和抵達都延遲超過 10 分鐘。由於資料表中的機場代碼值是包含雙引號 (例如 "SEA") 的字串，因此會被反斜線逸出，並被單引號括住。  

```
aws athena create-named-query \
    --name "SEA to JFK delayed flights Jan 2016" \
    --description "Both arrival and departure delayed more than 10 minutes." \
    --database sampledb \
    --query-string "SELECT flightdate, carrier, flightnum, origin, dest, depdelayminutes, arrdelayminutes FROM sampledb.flights_parquet WHERE yr = 2016 AND month = 1 AND origin = '\"SEA\"' AND dest = '\"JFK\"' AND depdelayminutes > 10 AND arrdelayminutes > 10" \
    --work-group AthenaAdmin
```
輸出：  

```
{
    "NamedQueryId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateNamedQuery](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/create-named-query.html)。

### `create-work-group`
<a name="athena_CreateWorkGroup_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-work-group`。

**AWS CLI**  
**建立工作群組**  
下列 `create-work-group` 範例建立名為 `Data_Analyst_Group` 的工作群組，其中具有查詢結果輸出位置 `s3://amzn-s3-demo-bucket`。命令會建立覆寫用戶端組態設定的工作群組，其中包含查詢結果輸出位置。命令也會啟用 CloudWatch 指標，並將三個鍵值標籤對加入至工作群組，以將其與其他工作群組區分開來。請注意，`--configuration` 引數中用於分隔選項的逗號前面沒有空格。  

```
aws athena create-work-group \
    --name Data_Analyst_Group \
    --configuration ResultConfiguration={OutputLocation="s3://amzn-s3-demo-bucket"},EnforceWorkGroupConfiguration="true",PublishCloudWatchMetricsEnabled="true" \
    --description "Workgroup for data analysts" \
    --tags Key=Division,Value=West Key=Location,Value=Seattle Key=Team,Value="Big Data"
```
此命令不會產生輸出。若要查看結果，請使用 `aws athena get-work-group --work-group Data_Analyst_Group`。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[管理工作群組](https://docs.aws.amazon.com/athena/latest/ug/workgroups-create-update-delete.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateWorkGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/create-work-group.html)。

### `delete-data-catalog`
<a name="athena_DeleteDataCatalog_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-data-catalog`。

**AWS CLI**  
**刪除資料目錄**  
下列 `delete-data-catalog` 範例會刪除 `UnusedDataCatalog` 資料目錄。  

```
aws athena delete-data-catalog \
    --name UnusedDataCatalog
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[刪除目錄：delete-data-catalog](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-deleting-a-catalog)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDataCatalog](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/delete-data-catalog.html)。

### `delete-named-query`
<a name="athena_DeleteNamedQuery_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-named-query`。

**AWS CLI**  
**刪除具名查詢**  
下列 `delete-named-query` 範例會刪除具有指定 ID 的具名查詢。  

```
aws athena delete-named-query \
    --named-query-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
此命令不會產生輸出。  
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteNamedQuery](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/delete-named-query.html)。

### `delete-work-group`
<a name="athena_DeleteWorkGroup_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-work-group`。

**AWS CLI**  
**刪除工作群組**  
以下 `delete-work-group` 範例會刪除 `TeamB` 工作群組。  

```
aws athena delete-work-group \
    --work-group TeamB
```
此命令不會產生輸出。若要確認刪除，請使用 `aws athena list-work-groups`。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[管理工作群組](https://docs.aws.amazon.com/athena/latest/ug/workgroups-create-update-delete.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteWorkGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/delete-work-group.html)。

### `get-data-catalog`
<a name="athena_GetDataCatalog_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-data-catalog`。

**AWS CLI**  
**傳回資料目錄的相關資訊**  
下列 `get-data-catalog` 範例會傳回 `dynamo_db_catalog` 資料目錄相關資訊。  

```
aws athena get-data-catalog \
    --name dynamo_db_catalog
```
輸出：  

```
{
    "DataCatalog": {
        "Name": "dynamo_db_catalog",
        "Description": "DynamoDB Catalog",
        "Type": "LAMBDA",
        "Parameters": {
            "catalog": "dynamo_db_catalog",
            "metadata-function": "arn:aws:lambda:us-west-2:111122223333:function:dynamo_db_lambda",
            "record-function": "arn:aws:lambda:us-west-2:111122223333:function:dynamo_db_lambda"
        }
    }
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[顯示目錄詳細資訊：get-data-catalog](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-showing-details-of-a-catalog)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDataCatalog](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-data-catalog.html)。

### `get-database`
<a name="athena_GetDatabase_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-database`。

**AWS CLI**  
**傳回資料目錄中資料庫的相關資訊**  
下列 `get-database` 範例會傳回 `AwsDataCatalog` 資料目錄中的 `sampledb` 資料庫的相關資訊。  

```
aws athena get-database \
    --catalog-name AwsDataCatalog \
    --database-name sampledb
```
輸出：  

```
{
    "Database": {
        "Name": "sampledb",
        "Description": "Sample database",
        "Parameters": {
            "CreatedBy": "Athena",
            "EXTERNAL": "TRUE"
        }
    }
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[顯示資料庫詳細資訊：get-database](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-showing-details-of-a-database)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDatabase](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-database.html)。

### `get-named-query`
<a name="athena_GetNamedQuery_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-named-query`。

**AWS CLI**  
**傳回具名查詢**  
下列 `get-named-query` 範例會傳回具有指定 ID 的查詢的相關資訊。  

```
aws athena get-named-query \
    --named-query-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
輸出：  

```
{
    "NamedQuery": {
        "Name": "CloudFront Logs - SFO",
        "Description": "Shows successful GET request data for SFO",
        "Database": "default",
        "QueryString": "select date, location, browser, uri, status from cloudfront_logs where method = 'GET' and status = 200 and location like 'SFO%' limit 10",
        "NamedQueryId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "WorkGroup": "AthenaAdmin"
    }
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetNamedQuery](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-named-query.html)。

### `get-query-execution`
<a name="athena_GetQueryExecution_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-query-execution`。

**AWS CLI**  
**傳回查詢執行的相關資訊。**  
下列 `get-query-execution` 範例會傳回具有指定查詢 ID 的查詢手相關資訊。  

```
aws athena get-query-execution \
    --query-execution-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
輸出：  

```
{
    "QueryExecution": {
        "QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "Query": "select date, location, browser, uri, status from cloudfront_logs where method = 'GET
' and status = 200 and location like 'SFO%' limit 10",
        "StatementType": "DML",
        "ResultConfiguration": {
            "OutputLocation": "s3://amzn-s3-demo-bucket/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111.csv"
        },
        "QueryExecutionContext": {
            "Database": "mydatabase",
            "Catalog": "awsdatacatalog"
        },
        "Status": {
            "State": "SUCCEEDED",
            "SubmissionDateTime": 1593469842.665,
            "CompletionDateTime": 1593469846.486
        },
        "Statistics": {
            "EngineExecutionTimeInMillis": 3600,
            "DataScannedInBytes": 203089,
            "TotalExecutionTimeInMillis": 3821,
            "QueryQueueTimeInMillis": 267,
            "QueryPlanningTimeInMillis": 1175
        },
        "WorkGroup": "AthenaAdmin"
    }
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetQueryExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-query-execution.html)。

### `get-query-results`
<a name="athena_GetQueryResults_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-query-results`。

**AWS CLI**  
**傳回查詢的結果**  
下列 `get-query-results` 範例會傳回具有指定查詢 ID 的查詢結果。  

```
aws athena get-query-results \
    --query-execution-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
輸出：  

```
{
    "ResultSet": {
        "Rows": [
            {
                "Data": [
                    {
                        "VarCharValue": "date"
                    },
                    {
                        "VarCharValue": "location"
                    },
                    {
                        "VarCharValue": "browser"
                    },
                    {
                        "VarCharValue": "uri"
                    },
                    {
                        "VarCharValue": "status"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Safari"
                    },
                    {
                        "VarCharValue": "/test-image-2.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Opera"
                    },
                    {
                        "VarCharValue": "/test-image-2.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Firefox"
                    },
                    {
                        "VarCharValue": "/test-image-3.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Lynx"
                    },
                    {
                        "VarCharValue": "/test-image-3.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "IE"
                    },
                    {
                        "VarCharValue": "/test-image-2.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Opera"
                    },
                    {
                        "VarCharValue": "/test-image-1.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Chrome"
                    },
                    {
                        "VarCharValue": "/test-image-3.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Firefox"
                    },
                    {
                        "VarCharValue": "/test-image-2.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "Chrome"
                    },
                    {
                        "VarCharValue": "/test-image-3.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            },
            {
                "Data": [
                    {
                        "VarCharValue": "2014-07-05"
                    },
                    {
                        "VarCharValue": "SFO4"
                    },
                    {
                        "VarCharValue": "IE"
                    },
                    {
                        "VarCharValue": "/test-image-2.jpeg"
                    },
                    {
                        "VarCharValue": "200"
                    }
                ]
            }
        ],
        "ResultSetMetadata": {
            "ColumnInfo": [
                {
                    "CatalogName": "hive",
                    "SchemaName": "",
                    "TableName": "",
                    "Name": "date",
                    "Label": "date",
                    "Type": "date",
                    "Precision": 0,
                    "Scale": 0,
                    "Nullable": "UNKNOWN",
                    "CaseSensitive": false
                },
                {
                    "CatalogName": "hive",
                    "SchemaName": "",
                    "TableName": "",
                    "Name": "location",
                    "Label": "location",
                    "Type": "varchar",
                    "Precision": 2147483647,
                "Data": [

                    "Scale": 0,
                    "Nullable": "UNKNOWN",
                    "CaseSensitive": true
                },
                {
                    "CatalogName": "hive",
                    "SchemaName": "",
                    "TableName": "",
                    "Name": "browser",
                    "Label": "browser",
                    "Type": "varchar",
                    "Precision": 2147483647,
                    "Scale": 0,
                    "Nullable": "UNKNOWN",
                    "CaseSensitive": true
                },
                {
                    "CatalogName": "hive",
                    "SchemaName": "",
                    "TableName": "",
                    "Name": "uri",
                    "Label": "uri",
                    "Type": "varchar",
                    "Precision": 2147483647,
                    "Scale": 0,
                    "Nullable": "UNKNOWN",
                    "CaseSensitive": true
                },
                {
                    "CatalogName": "hive",
                    "SchemaName": "",
                    "TableName": "",
                    "Name": "status",
                    "Label": "status",
                    "Type": "integer",
                    "Precision": 10,
                    "Scale": 0,
                    "Nullable": "UNKNOWN",
                    "CaseSensitive": false
                }
            ]
        }
    },
    "UpdateCount": 0
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[使用查詢結果、輸出檔案和查詢歷史記錄](https://docs.aws.amazon.com/athena/latest/ug/querying.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetQueryResults](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-query-results.html)。

### `get-table-metadata`
<a name="athena_GetTableMetadata_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-table-metadata`。

**AWS CLI**  
**傳回有關資料表的中繼資料資訊**  
下列 `get-table-metadata` 範例從 `AwsDataCatalog` 資料目錄的 `sampledb` 資料庫傳回有關 `counties` 資料表的中繼資料資訊，包括欄名及其資料類型。  

```
aws athena get-table-metadata \
    --catalog-name AwsDataCatalog \
    --database-name sampledb \
    --table-name counties
```
輸出：  

```
{
    "TableMetadata": {
        "Name": "counties",
        "CreateTime": 1593559968.0,
        "LastAccessTime": 0.0,
        "TableType": "EXTERNAL_TABLE",
        "Columns": [
            {
                "Name": "name",
                "Type": "string",
                "Comment": "from deserializer"
            },
            {
                "Name": "boundaryshape",
                "Type": "binary",
                "Comment": "from deserializer"
            },
            {
                "Name": "motto",
                "Type": "string",
                "Comment": "from deserializer"
            },
            {
                "Name": "population",
                "Type": "int",
                "Comment": "from deserializer"
            }
        ],
        "PartitionKeys": [],
        "Parameters": {
            "EXTERNAL": "TRUE",
            "inputformat": "com.esri.json.hadoop.EnclosedJsonInputFormat",
            "location": "s3://amzn-s3-demo-bucket/json",
            "outputformat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
            "serde.param.serialization.format": "1",
            "serde.serialization.lib": "com.esri.hadoop.hive.serde.JsonSerde",
            "transient_lastDdlTime": "1593559968"
        }
    }
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[顯示資料表詳細資訊：get-table-metadata](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-showing-details-of-a-table)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetTableMetadata](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-table-metadata.html)。

### `get-work-group`
<a name="athena_GetWorkGroup_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-work-group`。

**AWS CLI**  
**傳回工作群組的相關資訊**  
下列 `get-work-group` 範例會傳回 `AthenaAdmin` 工作群組的相關資訊。  

```
aws athena get-work-group \
    --work-group AthenaAdmin
```
輸出：  

```
{
    "WorkGroup": {
        "Name": "AthenaAdmin",
        "State": "ENABLED",
        "Configuration": {
            "ResultConfiguration": {
                "OutputLocation": "s3://amzn-s3-demo-bucket/"
            },
            "EnforceWorkGroupConfiguration": false,
            "PublishCloudWatchMetricsEnabled": true,
            "RequesterPaysEnabled": false
        },
        "Description": "Workgroup for Athena administrators",
        "CreationTime": 1573677174.105
    }
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[管理工作群組](https://docs.aws.amazon.com/athena/latest/ug/workgroups-create-update-delete.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetWorkGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/get-work-group.html)。

### `list-data-catalogs`
<a name="athena_ListDataCatalogs_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-data-catalogs`。

**AWS CLI**  
**列出在 Athena 註冊的資料目錄**  
下列 `list-data-catalogs` 範例列出在 Athena 註冊的資料目錄。  

```
aws athena list-data-catalogs
```
輸出：  

```
{
    "DataCatalogsSummary": [
        {
            "CatalogName": "AwsDataCatalog",
            "Type": "GLUE"
        },
        {
            "CatalogName": "cw_logs_catalog",
            "Type": "LAMBDA"
        },
        {
            "CatalogName": "cw_metrics_catalog",
            "Type": "LAMBDA"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[列出註冊的目錄：list-data-catalogs](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-listing-registered-catalogs)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListDataCatalogs](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-data-catalogs.html)。

### `list-databases`
<a name="athena_ListDatabases_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-databases`。

**AWS CLI**  
**列出資料目錄中的資料庫**  
下列 `list-databases` 範例列出 `AwsDataCatalog` 資料目錄的資料庫。  

```
aws athena list-databases \
    --catalog-name AwsDataCatalog
```
輸出：  

```
{
    "DatabaseList": [
        {
            "Name": "default"
        },
        {
            "Name": "mydatabase"
        },
        {
            "Name": "newdb"
        },
        {
            "Name": "sampledb",
            "Description": "Sample database",
            "Parameters": {
                "CreatedBy": "Athena",
                "EXTERNAL": "TRUE"
            }
        },
        {
            "Name": "webdata"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[列出目錄中的資料庫：list-databases](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-listing-databases)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListDatabases](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-databases.html)。

### `list-named-queries`
<a name="athena_ListNamedQueries_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-named-queries`。

**AWS CLI**  
**列出工作群組的具名查詢**  
下列 `list-named-queries` 範例列出 `AthenaAdmin` 工作群組的具名查詢。  

```
aws athena list-named-queries \
    --work-group AthenaAdmin
```
輸出：  

```
{
    "NamedQueryIds": [
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333"
    ]
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListNamedQueries](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-named-queries.html)。

### `list-query-executions`
<a name="athena_ListQueryExecutions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-query-executions`。

**AWS CLI**  
**列出指定之工作群組中的查詢 ID**  
下列 `list-query-executions` 範例列出 `AthenaAdmin` 工作群組中最多十個查詢 ID。  

```
aws athena list-query-executions \
    --work-group AthenaAdmin \
    --max-items 10
```
輸出：  

```
{
    "QueryExecutionIds": [
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11110",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11114",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11115",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11116",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11117",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11118",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11119"
    ],
    "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxMH0="
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[使用查詢結果、輸出檔案和查詢歷史記錄](https://docs.aws.amazon.com/athena/latest/ug/querying.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListQueryExecutions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-query-executions.html)。

### `list-table-metadata`
<a name="athena_ListTableMetadata_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-table-metadata`。

**AWS CLI**  
**列出資料目錄之指定資料庫中資料表的中繼資料**  
下列 `list-table-metadata` 範例會傳回 `AwsDataCatalog` 資料目錄 `geography` 資料庫中最多兩個資料表的中繼資料資訊。  

```
aws athena list-table-metadata \
    --catalog-name AwsDataCatalog \
    --database-name geography \
    --max-items 2
```
輸出：  

```
{
    "TableMetadataList": [
        {
            "Name": "country_codes",
            "CreateTime": 1586553454.0,
            "TableType": "EXTERNAL_TABLE",
            "Columns": [
                {
                    "Name": "country",
                    "Type": "string",
                    "Comment": "geo id"
                },
                {
                    "Name": "alpha-2 code",
                    "Type": "string",
                    "Comment": "geo id2"
                },
                {
                    "Name": "alpha-3 code",
                    "Type": "string",
                    "Comment": "state name"
                },
                {
                    "Name": "numeric code",
                    "Type": "bigint",
                    "Comment": ""
                },
                {
                    "Name": "latitude",
                    "Type": "bigint",
                    "Comment": "location (latitude)"
                },
                {
                    "Name": "longitude",
                    "Type": "bigint",
                    "Comment": "location (longitude)"
                }
            ],
            "Parameters": {
                "areColumnsQuoted": "false",
                "classification": "csv",
                "columnsOrdered": "true",
                "delimiter": ",",
                "has_encrypted_data": "false",
                "inputformat": "org.apache.hadoop.mapred.TextInputFormat",
                "location": "s3://amzn-s3-demo-bucket/csv/countrycode",
                "outputformat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
                "serde.param.field.delim": ",",
                "serde.serialization.lib": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe",
                "skip.header.line.count": "1",
                "typeOfData": "file"
            }
        },
        {
            "Name": "county_populations",
            "CreateTime": 1586553446.0,
            "TableType": "EXTERNAL_TABLE",
            "Columns": [
                {
                    "Name": "id",
                    "Type": "string",
                    "Comment": "geo id"
                },
                {
                    "Name": "country",

                    "Name": "id2",
                    "Type": "string",
                    "Comment": "geo id2"
                },
                {
                    "Name": "county",
                    "Type": "string",
                    "Comment": "county name"
                },
                {
                    "Name": "state",
                    "Type": "string",
                    "Comment": "state name"
                },
                {
                    "Name": "population estimate 2018",
                    "Type": "string",
                    "Comment": ""
                }
            ],
            "Parameters": {
                "areColumnsQuoted": "false",
                "classification": "csv",
                "columnsOrdered": "true",
                "delimiter": ",",
                "has_encrypted_data": "false",
                "inputformat": "org.apache.hadoop.mapred.TextInputFormat",
                "location": "s3://amzn-s3-demo-bucket/csv/CountyPopulation",
                "outputformat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
                "serde.param.field.delim": ",",
                "serde.serialization.lib": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe",
                "skip.header.line.count": "1",
                "typeOfData": "file"
            }
        }
    ],
    "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ=="
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[顯示資料庫中所有資料表的中繼資料：list-table-metadata](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-showing-all-table-metadata)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTableMetadata](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-table-metadata.html)。

### `list-tags-for-resource`
<a name="athena_ListTagsForResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-tags-for-resource`。

**AWS CLI**  
**範例 1：列出工作群組的標籤**  
下列 `list-tags-for-resource` 範例列出 `Data_Analyst_Group` 工作群組的標籤。  

```
aws athena list-tags-for-resource \
    --resource-arn arn:aws:athena:us-west-2:111122223333:workgroup/Data_Analyst_Group
```
輸出：  

```
{
    "Tags": [
        {
            "Key": "Division",
            "Value": "West"
        },
        {
            "Key": "Team",
            "Value": "Big Data"
        },
        {
            "Key": "Location",
            "Value": "Seattle"
        }
    ]
}
```
**範例 2：列出資料目錄的標籤**  
下列 `list-tags-for-resource` 範例列出 `dynamo_db_catalog` 資料目錄的標籤。  

```
aws athena list-tags-for-resource \
    --resource-arn arn:aws:athena:us-west-2:111122223333:datacatalog/dynamo_db_catalog
```
輸出：  

```
{
    "Tags": [
        {
            "Key": "Division",
            "Value": "Mountain"
        },
        {
            "Key": "Organization",
            "Value": "Retail"
        },
        {
            "Key": "Product_Line",
            "Value": "Shoes"
        },
        {
            "Key": "Location",
            "Value": "Denver"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[列出資源的標籤：list-tags-for-resource](https://docs.aws.amazon.com/athena/latest/ug/tags-operations.html#tags-operations-examples-cli-list-tags-for-resource)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-tags-for-resource.html)。

### `list-work-groups`
<a name="athena_ListWorkGroups_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-work-groups`。

**AWS CLI**  
**列出工作群組**  
下列 `list-work-groups` 範例列出目前帳戶中的工作群組。  

```
aws athena list-work-groups
```
輸出：  

```
{
    "WorkGroups": [
        {
            "Name": "Data_Analyst_Group",
            "State": "ENABLED",
            "Description": "",
            "CreationTime": 1578006683.016
        },
        {
            "Name": "AthenaAdmin",
            "State": "ENABLED",
            "Description": "",
            "CreationTime": 1573677174.105
        },
        {
            "Name": "primary",
            "State": "ENABLED",
            "Description": "",
            "CreationTime": 1567465222.723
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[管理工作群組](https://docs.aws.amazon.com/athena/latest/ug/workgroups-create-update-delete.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListWorkGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/list-work-groups.html)。

### `start-query-execution`
<a name="athena_StartQueryExecution_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `start-query-execution`。

**AWS CLI**  
**範例 1：在工作群組中，針對指定資料庫和資料目錄中的指定資料表執行查詢**  
下列 `start-query-execution` 範例使用 `AthenaAdmin` 工作群組，在 `AwsDataCatalog` 資料目錄中 `cloudfront_logs` 的 `cflogsdatabase` 資料表上執行查詢。  

```
aws athena start-query-execution \
    --query-string "select date, location, browser, uri, status from cloudfront_logs where method = 'GET' and status = 200 and location like 'SFO%' limit 10" \
    --work-group "AthenaAdmin" \
    --query-execution-context Database=cflogsdatabase,Catalog=AwsDataCatalog
```
輸出：  

```
{
"QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
**範例 2：執行查詢，使用指定工作群組在指定的資料目錄中建立資料庫**  
下列 `start-query-execution` 範例使用 `AthenaAdmin` 工作群組在預設資料目錄 `AwsDataCatalog` 中建立資料庫 `newdb`。  

```
aws athena start-query-execution \
    --query-string "create database if not exists newdb" \
    --work-group "AthenaAdmin"
```
輸出：  

```
{
"QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11112"
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
**範例 3：執行查詢，在指定的資料庫和資料目錄中的資料表上建立檢視表**  
下列 `start-query-execution` 範例使用 `cflogsdatabase` 中 `cloudfront_logs` 資料表上的 `SELECT` 陳述式，建立檢視表 `cf10`。  

```
aws athena start-query-execution \
    --query-string  "CREATE OR REPLACE VIEW cf10 AS SELECT * FROM cloudfront_logs limit 10" \
    --query-execution-context Database=cflogsdatabase
```
輸出：  

```
{
"QueryExecutionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11113"
}
```
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StartQueryExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/start-query-execution.html)。

### `stop-query-execution`
<a name="athena_StopQueryExecution_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `stop-query-execution`。

**AWS CLI**  
**停止執行中的查詢**  
下列 `stop-query-execution` 範例停止具有指定查詢 ID 的查詢。  

```
aws athena stop-query-execution \
    --query-execution-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
此命令不會產生輸出。  
如需詳細資訊，請參閱 *Amazon Athena 使用者指南*中的[使用 Amazon Athena 執行 SQL 查詢](https://docs.aws.amazon.com/athena/latest/ug/querying-athena-tables.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StopQueryExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/stop-query-execution.html)。

### `tag-resource`
<a name="athena_TagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `tag-resource`。

**AWS CLI**  
**將標籤加入資源**  
下列 `tag-resource` 範例將三個標籤新增至 `dynamo_db_catalog` 資料目錄。  

```
aws athena tag-resource \
    --resource-arn arn:aws:athena:us-west-2:111122223333:datacatalog/dynamo_db_catalog \
    --tags Key=Organization,Value=Retail Key=Division,Value=Mountain Key=Product_Line,Value=Shoes Key=Location,Value=Denver
```
此命令不會產生輸出。若要查看結果，請使用 `aws athena list-tags-for-resource --resource-arn arn:aws:athena:us-west-2:111122223333:datacatalog/dynamo_db_catalog`。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[將標籤新增至資源：tag-resource](https://docs.aws.amazon.com/athena/latest/ug/tags-operations.html#tags-operations-examples-cli-tag-resource)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/tag-resource.html)。

### `untag-resource`
<a name="athena_UntagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `untag-resource`。

**AWS CLI**  
**將標籤從資源中移除**  
下列 `untag-resource` 範例從 `dynamo_db_catalog` 資料目錄資源移除 `Specialization` 和 `Focus` 索引鍵及其關聯值。  

```
aws athena untag-resource \
    --resource-arn arn:aws:athena:us-west-2:111122223333:datacatalog/dynamo_db_catalog \
    --tag-keys Specialization Focus
```
此命令不會產生輸出。若要顯示結果，請使用 `list-tags-for-resource` 命令。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[從資源移除標籤：untag-resource](https://docs.aws.amazon.com/athena/latest/ug/tags-operations.html#tags-operations-examples-cli-untag-resource)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/untag-resource.html)。

### `update-data-catalog`
<a name="athena_UpdateDataCatalog_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-data-catalog`。

**AWS CLI**  
**更新資料目錄**  
下列 `update-data-catalog` 範例會更新 Lambda 函式和 `cw_logs_catalog` 資料目錄的描述。  

```
aws athena update-data-catalog \
    --name cw_logs_catalog \
    --type LAMBDA \
    --description "New CloudWatch Logs Catalog" \
    --function=arn:aws:lambda:us-west-2:111122223333:function:new_cw_logs_lambda
```
此命令不會產生輸出。若要查看結果，請使用 `aws athena get-data-catalog --name cw_logs_catalog`。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[更新目錄：update-data-catalog](https://docs.aws.amazon.com/athena/latest/ug/datastores-hive-cli.html#datastores-hive-cli-updating-a-catalog)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateDataCatalog](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/update-data-catalog.html)。

### `update-work-group`
<a name="athena_UpdateWorkGroup_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-work-group`。

**AWS CLI**  
**更新工作群組**  
下列 `update-work-group` 範例停用 `Data_Analyst_Group` 工作群組。使用者無法在已停用的工作群組中執行或建立查詢，但仍可以檢視指標、資料用量限制控制、工作群組設定、查詢歷史記錄和已儲存的查詢。  

```
aws athena update-work-group \
    --work-group Data_Analyst_Group \
    --state DISABLED
```
此命令不會產生輸出。若要驗證狀態的變化，請使用 `aws athena get-work-group --work-group Data_Analyst_Group` 並檢查輸出中的 `State` 屬性。  
如需詳細資訊，請參閱《*Amazon Athena 使用者指南*》中的[管理工作群組](https://docs.aws.amazon.com/athena/latest/ug/workgroups-create-update-delete.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateWorkGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/athena/update-work-group.html)。