

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

# 設定存取預備陳述式
<a name="security-iam-athena-prepared-statements"></a>

本主題涵蓋 中預備陳述式的 IAM 許可 Amazon Athena。每當您使用 IAM 政策時，請務必遵循 IAM 最佳實務。如需詳細資訊，請參閱《IAM 使用者指南》**中的 [IAM 中的安全性最佳實務](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)。

如需有關預備陳述式的詳細資訊，請參閱[使用參數化查詢](querying-with-prepared-statements.md)。

建立、管理和執行預備陳述式時，需要下列 IAM 許可。

```
athena:CreatePreparedStatement
athena:UpdatePreparedStatement
athena:GetPreparedStatement
athena:ListPreparedStatements
athena:DeletePreparedStatement
```

如以下資料表所示方式使用這些許可。


****  

| 若要執行此作業 | 使用這些許可 | 
| --- | --- | 
| 執行 PREPARE 查詢 | athena:StartQueryExecution athena:CreatePreparedStatement | 
| 重新執行 PREPARE 查詢以更新現有的預備陳述式 | athena:StartQueryExecution athena:UpdatePreparedStatement | 
| 執行 EXECUTE 查詢 | athena:StartQueryExecution athena:GetPreparedStatement | 
| 執行 DEALLOCATE PREPARE 查詢 | athena:StartQueryExecution athena:DeletePreparedStatement | 

## 範例
<a name="security-iam-athena-prepared-statements-example"></a>

以下 IAM 政策範例授予許可，以在指定的帳戶 ID 和工作群組上管理和執行預備陳述式。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "athena:StartQueryExecution",
                "athena:CreatePreparedStatement",
                "athena:UpdatePreparedStatement",
                "athena:GetPreparedStatement",
                "athena:DeletePreparedStatement",
                "athena:ListPreparedStatements"
            ],
            "Resource": [
                "arn:aws:athena:*:111122223333:workgroup/<workgroup-name>"
            ]
        }
    ]
}
```

------