

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

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

# 使用 Tools for PowerShell V5 的 DynamoDB 範例
<a name="powershell_5_dynamodb_code_examples"></a>

下列程式碼範例示範如何使用 AWS Tools for PowerShell V5 搭配 DynamoDB 來執行動作和實作常見案例。

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

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

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

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

### `Add-DDBIndexSchema`
<a name="dynamodb_Add-DDBIndexSchema_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：建立空的 TableSchema 物件，並在將 TableSchema 物件寫入管道之前，為其新增本機次要索引定義。**  

```
$schema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
$schema = New-DDBTableSchema
```
**輸出：**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{LastPostDateTime}                          {}                                          {LastPostIndex}
```
**範例 2：將新的本機次要索引定義新增至提供的 TableSchema 物件，然後再將 TableSchema 物件寫入管道。也可以使用 -Schema 參數提供 TableSchema 物件。**  

```
New-DDBTableSchema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
```
**輸出：**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{LastPostDateTime}                          {}                                          {LastPostIndex}
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [Add-DDBIndexSchema](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Add-DDBKeySchema`
<a name="dynamodb_Add-DDBKeySchema_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：建立空的 TableSchema 物件，並使用指定的索引鍵資料，將索引鍵和屬性定義項目新增至其中，然後才能將 TableSchema 物件寫入管道。根據預設，索引鍵類型宣告為 'HASH'；使用值為 'RANGE' 的 -KeyType paameter 宣告範圍索引鍵。**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
```
**輸出：**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{ForumName}                                 {ForumName}                                 {}
```
**範例 2：在將 TableSchema 物件寫入管道之前，將新的索引鍵和屬性定義項目新增至提供的 TableSchema 物件。根據預設，索引鍵類型宣告為 'HASH'；使用值為 'RANGE' 的 -KeyType paameter 宣告範圍索引鍵。也可以使用 -Schema 參數提供 TableSchema 物件。**  

```
New-DDBTableSchema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
```
**輸出：**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{ForumName}                                 {ForumName}                                 {}
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [Add-DDBKeySchema](https://docs.aws.amazon.com/powershell/v5/reference)。

### `ConvertFrom-DDBItem`
<a name="dynamodb_ConvertFrom-DDBItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：ConvertFrom-DDBItem 用於將 Get-DDBItem 的結果，從 DynamoDB AttributeValues 的雜湊表轉換為字串和雙精度等常見類型的雜湊表。**  

```
@{
    SongTitle = 'Somewhere Down The Road'
    Artist    = 'No One You Know'
} | ConvertTo-DDBItem

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [ConvertFrom-DDBItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `ConvertTo-DDBItem`
<a name="dynamodb_ConvertTo-DDBItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：將雜湊表轉換為 DynamoDB 屬性值的字典範例。**  

```
@{
    SongTitle = 'Somewhere Down The Road'
    Artist    = 'No One You Know'
} | ConvertTo-DDBItem

Key       Value
---       -----
SongTitle Amazon.DynamoDBv2.Model.AttributeValue
Artist    Amazon.DynamoDBv2.Model.AttributeValue
```
**範例 2：將雜湊表轉換為 DynamoDB 屬性值的字典範例。**  

```
@{
    MyMap        = @{
        MyString = 'my string'
    }
    MyStringSet  = [System.Collections.Generic.HashSet[String]]@('my', 'string')
    MyNumericSet = [System.Collections.Generic.HashSet[Int]]@(1, 2, 3)
    MyBinarySet  = [System.Collections.Generic.HashSet[System.IO.MemoryStream]]@(
        ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes('my'))),
        ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes('string')))
    )
    MyList1      = @('my', 'string')
    MyList2      = [System.Collections.Generic.List[Int]]@(1, 2)
    MyList3      = [System.Collections.ArrayList]@('one', 2, $true)
} | ConvertTo-DDBItem
```
**輸出：**  

```
Key          Value
---          -----
MyStringSet  Amazon.DynamoDBv2.Model.AttributeValue
MyList1      Amazon.DynamoDBv2.Model.AttributeValue
MyNumericSet Amazon.DynamoDBv2.Model.AttributeValue
MyList2      Amazon.DynamoDBv2.Model.AttributeValue
MyBinarySet  Amazon.DynamoDBv2.Model.AttributeValue
MyMap        Amazon.DynamoDBv2.Model.AttributeValue
MyList3      Amazon.DynamoDBv2.Model.AttributeValue
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [ConvertTo-DDBItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-DDBBatchItem`
<a name="dynamodb_BatchGetItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：從 DynamoDB 資料表 'Music' 和 'Songs' 取得具有 SongTitle "Somewhere Down The Road" 的項目。**  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem

$keysAndAttributes = New-Object Amazon.DynamoDBv2.Model.KeysAndAttributes
$list = New-Object 'System.Collections.Generic.List[System.Collections.Generic.Dictionary[String, Amazon.DynamoDBv2.Model.AttributeValue]]'
$list.Add($key)
$keysAndAttributes.Keys = $list

$requestItem = @{
    'Music' = [Amazon.DynamoDBv2.Model.KeysAndAttributes]$keysAndAttributes
    'Songs' = [Amazon.DynamoDBv2.Model.KeysAndAttributes]$keysAndAttributes
}

$batchItems = Get-DDBBatchItem -RequestItem $requestItem
$batchItems.GetEnumerator() | ForEach-Object {$PSItem.Value} | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Artist                         No One You Know
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
CriticRating                   10
Genre                          Country
Price                          1.94
Artist                         No One You Know
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
CriticRating                   10
Genre                          Country
Price                          1.94
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [BatchGetItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-DDBItem`
<a name="dynamodb_GetItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：使用分割區索引鍵 SongTitle 和排序索引鍵 Artist 傳回 DynamoDB 項目。**  

```
$key = @{
  SongTitle = 'Somewhere Down The Road'
  Artist = 'No One You Know'
} | ConvertTo-DDBItem

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Country
SongTitle                      Somewhere Down The Road
Price                          1.94
Artist                         No One You Know
CriticRating                   9
AlbumTitle                     Somewhat Famous
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [GetItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-DDBTable`
<a name="dynamodb_DescribeTable_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：傳回指定資料表的詳細資訊。**  

```
Get-DDBTable -TableName "myTable"
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DescribeTable](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Get-DDBTableList`
<a name="dynamodb_ListTables_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：傳回所有資料表的詳細資訊，自動迭代，直到服務指出不存在其他資料表為止。**  

```
Get-DDBTableList
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [ListTables](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Invoke-DDBQuery`
<a name="dynamodb_Query_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：調用查詢，傳回具有指定之 SongTitle 和 Artist 的 DynamoDB 項目。**  

```
$invokeDDBQuery = @{
    TableName = 'Music'
    KeyConditionExpression = ' SongTitle = :SongTitle and Artist = :Artist'
    ExpressionAttributeValues = @{
        ':SongTitle' = 'Somewhere Down The Road'
        ':Artist' = 'No One You Know'
    } | ConvertTo-DDBItem
}
Invoke-DDBQuery @invokeDDBQuery | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [Query](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Invoke-DDBScan`
<a name="dynamodb_Scan_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：傳回 Music 資料表中的所有項目。**  

```
Invoke-DDBScan -TableName 'Music' | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
Genre                          Country
Artist                         No One You Know
Price                          1.98
CriticRating                   8.4
SongTitle                      My Dog Spot
AlbumTitle                     Hey Now
```
**範例 2：傳回 Music 資料表中 CriticRating 大於或等於九的項目。**  

```
$scanFilter = @{
        CriticRating = [Amazon.DynamoDBv2.Model.Condition]@{
            AttributeValueList = @(@{N = '9'})
            ComparisonOperator = 'GE'
        }
    }
    Invoke-DDBScan -TableName 'Music' -ScanFilter $scanFilter | ConvertFrom-DDBItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [Scan](https://docs.aws.amazon.com/powershell/v5/reference)。

### `New-DDBTable`
<a name="dynamodb_CreateTable_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：此範例會建立名為 Thread 的資料表，其主索引鍵包含 'ForumName' (索引鍵類型雜湊) 和 'Subject' (索引鍵類型範圍)。用來建構資料表的結構描述，可以使用 -Schema 參數，依照所示或指定方式輸送至每個 cmdlet。**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyType RANGE -KeyDataType "S"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**輸出：**  

```
AttributeDefinitions   : {ForumName, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {}
```
**範例 2：此範例會建立名為 Thread 的資料表，其主索引鍵包含 'ForumName' (索引鍵類型雜湊) 和 'Subject' (索引鍵類型範圍)。也會定義本機次要索引。本機次要索引的索引鍵會從資料表 (ForumName) 上的主要雜湊索引鍵自動設定。用來建構資料表的結構描述，可以使用 -Schema 參數，依照所示或指定方式輸送至每個 cmdlet。**  

```
$schema = New-DDBTableSchema
$schema | Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S"
$schema | Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S"
$schema | Add-DDBIndexSchema -IndexName "LastPostIndex" -RangeKeyName "LastPostDateTime" -RangeKeyDataType "S" -ProjectionType "keys_only"
$schema | New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**輸出：**  

```
AttributeDefinitions   : {ForumName, LastPostDateTime, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {LastPostIndex}
```
**範例 3：此範例示範如何使用單一管道建立名為 Thread 的資料表，該資料表的主索引鍵包含 'ForumName' (索引鍵類型雜湊) 和 'Subject' (索引鍵類型範圍) 以及本機次要索引。如果管道或 -Schema 參數未提供新的 TableSchema 物件，Add-DDBKeySchema 和 Add-DDBIndexSchema 會為您建立新的 TableSchema 物件。**  

```
New-DDBTableSchema |
  Add-DDBKeySchema -KeyName "ForumName" -KeyDataType "S" |
  Add-DDBKeySchema -KeyName "Subject" -KeyDataType "S" |
  Add-DDBIndexSchema -IndexName "LastPostIndex" `
                     -RangeKeyName "LastPostDateTime" `
                     -RangeKeyDataType "S" `
                     -ProjectionType "keys_only" |
  New-DDBTable -TableName "Thread" -ReadCapacity 10 -WriteCapacity 5
```
**輸出：**  

```
AttributeDefinitions   : {ForumName, LastPostDateTime, Subject}
TableName              : Thread
KeySchema              : {ForumName, Subject}
TableStatus            : CREATING
CreationDateTime       : 10/28/2013 4:39:49 PM
ProvisionedThroughput  : Amazon.DynamoDBv2.Model.ProvisionedThroughputDescription
TableSizeBytes         : 0
ItemCount              : 0
LocalSecondaryIndexes  : {LastPostIndex}
```
+  如需 API 詳細資訊，請參閱*《AWS Tools for PowerShell Cmdlet 參考 (V5)》*中的 [CreateTable](https://docs.aws.amazon.com/powershell/v5/reference)。

### `New-DDBTableSchema`
<a name="dynamodb_New-DDBTableSchema_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：建立空 TableSchema 物件，準備好接受鍵和索引定義，以用於建立新的 Amazon DynamoDB 資料表。傳回的物件可以透過管道傳輸到 Add-DDBKeySchema、Add-DDBIndexSchema 和 New-DDBTable Cmdlet，或使用每個 Cmdlet 上的 -Schema 參數傳遞給它們。**  

```
New-DDBTableSchema
```
**輸出：**  

```
AttributeSchema                             KeySchema                                   LocalSecondaryIndexSchema
---------------                             ---------                                   -------------------------
{}                                          {}                                          {}
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [New-DDBTableSchema](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Remove-DDBItem`
<a name="dynamodb_DeleteItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：移除符合所提供索引鍵的 DynamoDB 項目。**  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem
Remove-DDBItem -TableName 'Music' -Key $key -Confirm:$false
```
+  如需 API 詳細資訊，請參閱AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [DeleteItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Remove-DDBTable`
<a name="dynamodb_DeleteTable_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：刪除指定的資料表。在繼續操作之前，系統會提示您確認。**  

```
Remove-DDBTable -TableName "myTable"
```
**範例 2：刪除指定的資料表。在繼續操作之前，系統不會提示您進行確認。**  

```
Remove-DDBTable -TableName "myTable" -Force
```
+  如需 API 詳細資訊，請參閱*《AWS Tools for PowerShell Cmdlet 參考 (V5)》*中的 [DeleteTable](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Set-DDBBatchItem`
<a name="dynamodb_BatchWriteItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：建立新的項目，或將現有項目取代為 DynamoDB 資料表 Music 和 Songs 中的新項目。**  

```
$item = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
    AlbumTitle = 'Somewhat Famous'
    Price = 1.94
    Genre = 'Country'
    CriticRating = 10.0
} | ConvertTo-DDBItem

$writeRequest = New-Object Amazon.DynamoDBv2.Model.WriteRequest
$writeRequest.PutRequest = [Amazon.DynamoDBv2.Model.PutRequest]$item

$requestItem = @{
    'Music' = [Amazon.DynamoDBv2.Model.WriteRequest]($writeRequest)
    'Songs' = [Amazon.DynamoDBv2.Model.WriteRequest]($writeRequest)
}

Set-DDBBatchItem -RequestItem $requestItem
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [BatchWriteItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Set-DDBItem`
<a name="dynamodb_PutItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：建立新的項目，或將現有項目取代為新項目。**  

```
$item = @{
  SongTitle = 'Somewhere Down The Road'
  Artist = 'No One You Know'
        AlbumTitle = 'Somewhat Famous'
        Price = 1.94
        Genre = 'Country'
        CriticRating = 9.0
} | ConvertTo-DDBItem
Set-DDBItem -TableName 'Music' -Item $item
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [PutItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Update-DDBItem`
<a name="dynamodb_UpdateItem_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：使用分割區索引鍵 SongTitle 和排序索引鍵 Artist，將 DynamoDB 項目的類型屬性設定為 'Rap'**。  

```
$key = @{
    SongTitle = 'Somewhere Down The Road'
    Artist = 'No One You Know'
} | ConvertTo-DDBItem

$updateDdbItem = @{
    TableName = 'Music'
    Key = $key
    UpdateExpression = 'set Genre = :val1'
    ExpressionAttributeValue = (@{
        ':val1' = ([Amazon.DynamoDBv2.Model.AttributeValue]'Rap')
    })
}
Update-DDBItem @updateDdbItem
```
**輸出：**  

```
Name                           Value
----                           -----
Genre                          Rap
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [UpdateItem](https://docs.aws.amazon.com/powershell/v5/reference)。

### `Update-DDBTable`
<a name="dynamodb_UpdateTable_powershell_5_topic"></a>

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

**Tools for PowerShell V5**  
**範例 1：更新特定資料表的佈建輸送量。**  

```
Update-DDBTable -TableName "myTable" -ReadCapacity 10 -WriteCapacity 5
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [UpdateTable](https://docs.aws.amazon.com/powershell/v5/reference)。