

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Erste Schritte mit DynamoDB
<a name="GettingStartedDynamoDB"></a>

In den folgenden Abschnitten erfahren Sie, wie Sie eine Verbindung zu DynamoDB-Tabellen herstellen, diese erstellen und verwalten.

Bevor Sie beginnen, sollten Sie sich mit den Basic-Konzepten in Amazon DynamoDB vertraut machen. Einen schnellen Überblick über [Was ist Amazon DynamoDB?](Introduction.md) und einen tieferen Einblick erhalten Sie unter [Kernkomponenten von Amazon DynamoDB](HowItWorks.CoreComponents.md). Fahren Sie dann mit den [Voraussetzungen](#GettingStarted.SettingUp.DynamoWebService) fort.

**Anmerkung**  
Wenn Sie sich für anmelden AWS, können Sie mithilfe des [AWS kostenlosen](https://aws.amazon.com/free/) Kontingents mit DynamoDB beginnen. Sofern Sie das kostenlose Kontingent für Amazon DynamoDB noch nicht überschritten haben, können Sie die Beispiele in diesem Abschnitt kostenlos bearbeiten. Andernfalls fallen die üblichen DynamoDB-Nutzungsgebühren an, und zwar zwischen dem Zeitpunkt, an dem Sie sie erstellen, und zu dem Zeitpunkt, an dem Sie sie löschen.  
Wenn Sie sich nicht für ein Konto mit kostenlosem Kontingent registrieren möchten, können Sie die [ lokale Version von DynamoDB (herunterladbare Version)](DynamoDBLocal.md) auf dem Computer einrichten. Mit der herunterladbaren Version können Sie Anwendungen lokal entwickeln und testen, ohne sich für ein AWS Konto registrieren oder auf den DynamoDB-Webservice zugreifen zu müssen.

**Topics**
+ [Amazon DynamoDB-Ressourcen für Erstbenutzer](dynamodb-resources-first-time-users.md)
+ [Zugreifen auf DynamoDB](AccessingDynamoDB.md)
+ [Voraussetzungen](#GettingStarted.SettingUp.DynamoWebService)
+ [Einrichten von DynamoDB](SettingUp.md)
+ [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md)
+ [Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle](getting-started-step-2.md)
+ [Schritt 3: Lesen von Daten aus einer DynamoDB-Tabelle](getting-started-step-3.md)
+ [Schritt 4: Aktualisieren von Daten in einer DynamoDB-Tabelle](getting-started-step-4.md)
+ [Schritt 5: Abfragen der Daten in der DynamoDB-Tabelle](getting-started-step-5.md)
+ [Schritt 6: (Optional) Löschen der DynamoDB-Tabelle, um Ressourcen zu bereinigen](getting-started-step-6.md)
+ [Erfahren Sie mehr über DynamoDB](getting-started-NextSteps.md)
+ [Generieren Sie Infrastrukturcode für Amazon DynamoDB mit Console-to-Code](console-to-code.md)

# Amazon DynamoDB-Ressourcen für Erstbenutzer
<a name="dynamodb-resources-first-time-users"></a>

Wir empfehlen Erstbenutzern, mit der Lektüre der folgenden Abschnitte zu beginnen und bei Bedarf darauf zurückzugreifen.


|  |  | 
| --- |--- |
|  

**Example**  
**[Leistungsschwerpunkte und Preise](https://aws.amazon.com/dynamodb/)**  
Bietet einen allgemeinen Produktüberblick über DynamoDB, allgemeine Anwendungsfälle, Servicehighlights und Preise.  |  

**Example**  
**[DynamoDB-Ressourcen](https://aws.amazon.com/dynamodb/resources/)**  
Videos, Tutorials und Anleitungen, die Sie mit dem Service, den Konzepten der Datenmodellierung und den wichtigsten Funktionen und Fähigkeiten vertraut machen.  | 
|  

**Example**  
**[Erste Schritte](GettingStartedDynamoDB.md)**  
Informationen zum Einrichten von DynamoDB, zum Erstellen von Beispieltabellen und zum Hochladen von Daten.  |  

**Example**  
**[DynamoDB-Grundlagenkurs](https://explore.skillbuilder.aws/learn/course/external/view/elearning/16104/amazon-dynamodb-basics)**  
Kostenloser digitaler Kurs, der die Grundlagen von DynamoDB vermittelt, einschließlich Tabellendesign, Datentypen und Grundoperationen.  | 
|  

**Example**  
**[DynamoDB-Nuggets](https://www.youtube.com/playlist?list=PLhr1KZpdzukemNOO71Hca0GpjG0QmXwEd)**  
Kurze, gezielte Video-Tutorials, in denen die wichtigsten Konzepte und Funktionen von DynamoDB erklärt werden.  |  

**Example**  
**[DynamoDB-Codebeispiel-Repository](https://github.com/aws-samples/aws-dynamodb-examples)**  
Praktische DynamoDB-Codebeispiele in verschiedenen Programmiersprachen.  | 
|  

**Example**  
**[Kostenlose DynamoDB-Schulung](https://skillbuilder.aws/learn/WC3K4Y4S5N/amazon-dynamodb-getting-started/)**  
AWS bietet kostenlose digitale Schulungen, die sich mit Konzepten, Funktionen und bewährten Methoden von DynamoDB befassen.  |  

**Example**  
**[NoSQL Workbench für DynamoDB](https://youtu.be/p5va6ZX9_o0)**  
Einheitliches visuelles Tool, das Funktionen für Datenmodellierung, Datenvisualisierung und Abfrageentwicklung bietet.  | 
|  

**Example**  
**[DynamoDB-Entwurfsmuster](best-practices.md)**  
Bewährte Methoden und Beispiele für Datenmodellierung für verschiedene Anwendungsfälle mit praktischen Codebeispielen.  |  

**Example**  
**[Praktische Tutorials](https://aws.amazon.com/tutorials/create-nosql-table/)**  
Step-by-step Tutorials im AWS-Managementkonsole , die Sie durch allgemeine DynamoDB-Aufgaben führen.  | 
|  

**Example**  
**[Migration zu DynamoDB](migration-guide.md)**  
Überblick über den Prozess, die Tools und Strategien für die Migration einer Datenbank zu DynamoDB.  |  

**Example**  
**[AWS Well-Architected Objektiv für DynamoDB](bp-wal.md)**  
Bewährte Architekturpraktiken für die Entwicklung und den Betrieb zuverlässiger, sicherer, effizienter und kostengünstiger Anwendungen mit DynamoDB.  | 

## Zusätzliche bewährte Methoden für Amazon DynamoDB für Erstbenutzer
<a name="additional-reading"></a>

Wenn Sie die vorhergehenden Abschnitte abgeschlossen haben, lesen die folgenden:
+  **[DynamoDB-Durchsatzkapazität](capacity-mode.md)** 

  Bietet Überblick über die beiden Durchsatzmodi, die für Ihre DynamoDB-Tabelle verfügbar sind, sowie Überlegungen zur Auswahl des geeigneten Kapazitätsmodus für Ihre Anwendung. Der On-Demand-Modus ist die standardmäßige und empfohlene Durchsatzoption für die meisten DynamoDB-Workloads.
+  **[Bewährte Methoden für Design und Architektur mit DynamoDB](best-practices.md)** 

  Identifizieren und beheben Sie Probleme, um die Leistung zu maximieren und die Kosten bei der Arbeit mit DynamoDB zu minimieren.

## AWS CLI Ressourcen
<a name="new-users-aws-cli-resources"></a>

Wenn Sie die AWS Befehlszeilenschnittstelle (AWS CLI) verwenden möchten, können Sie diese Dokumente verwenden, um Ihnen den Einstieg zu erleichtern:
+  **[AWS CLI -Dokumentation](https://docs.aws.amazon.com/cli/)** 

   Dieser Abschnitt enthält Informationen zum Herunterladen von AWS CLI, zum AWS CLI Betrieb auf Ihrem System und zum Eingeben Ihrer AWS Anmeldeinformationen. 
+  **[AWS CLI Dokumentation für DynamoDB](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/index.html)** 

   Dieses separate Dokument behandelt alle Befehle AWS CLI für DynamoDB, einschließlich Syntax und Beispielen. 

## Programmierressourcen
<a name="new-user-programming-resources"></a>

Sie können Anwendungsprogramme unter Verwendung der DynamoDB-API mit einer Reihe gängiger Programmiersprachen erstellen. Nachfolgend finden Sie einige Ressourcen:
+  **[Tools für Amazon Web Services](https://aws.amazon.com/developer/tools/)** 

   AWS bietet eine Reihe von Software Development Kits (SDKs) mit Unterstützung für DynamoDB. Sie können Java, .NET, PHP, Ruby und andere Sprachen für die DynamoDB-Programmierung verwenden. Diese SDKs können Ihre Anwendungsentwicklung erheblich vereinfachen, indem sie Ihre Anfragen in DynamoDB formatieren, Antworten analysieren und Wiederholungslogik und Fehlerbehandlung bereitstellen. 
+  **[Referenz zur DynamoDB-API](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/Welcome.html)**

   Wenn Sie das nicht verwenden möchten AWS SDKs, können Sie über die DynamoDB-API direkt mit DynamoDB interagieren. In diesem separaten Dokument finden Sie alle DynamoDB-API-Operationen zusammen mit Syntax und Beispielen. In diesem Abschnitt finden Sie auch Tipps zur Fehlerbehebung sowie Informationen zur Erstellung und Authentifizierung von Anfragen und der Behandlung von Antworten. 

# Zugreifen auf DynamoDB
<a name="AccessingDynamoDB"></a>

 Sie können mit der AWS-Managementkonsole, der AWS Command Line Interface (AWS CLI) oder der DynamoDB-API auf Amazon DynamoDB zugreifen.

**Topics**
+ [Verwenden der Konsole](#ConsoleDynamoDB)
+ [Mit dem AWS CLI](#Tools.CLI)
+ [Verwenden der API](#Using.API)
+ [Verwenden von NoSQL-Workbench für DynamoDB](#Using.Workbench)
+ [IP-Adressbereiche](#Using.IPRanges)
+ [Dual-Stack-Endpunkte für Internet Protocol Version 6 () IPv6](#dual-stackipv4-6)

## Verwenden der Konsole
<a name="ConsoleDynamoDB"></a>

[Sie können zu Hause auf die AWS-Managementkonsole für Amazon DynamoDB zugreifen. https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/home)

Hier sind einige der Aktionen, die Sie in der DynamoDB-Konsole ausführen können:
+ **Tabellen verwalten**: Erstellen, aktualisieren und löschen Sie Tabellen. Der Kapazitätsrechner kann Ihnen helfen, den Kapazitätsbedarf abzuschätzen.
+ **Mit Daten interagieren**: Sie können Elemente in Ihren Tabellen anzeigen, hinzufügen, aktualisieren und löschen. Außerdem können Sie die Einstellungen für Time to Live (TTL) verwalten.
+ **Überwachen und analysieren**: Zeigen Sie Dashboards an, überwachen und richten Sie Alarme ein und analysieren Sie Metriken und Warnungen für Ihre DynamoDB-Tabellen.
+ **Optimieren und erweitern**: Verwalten Sie sekundäre Indizes, Streams, Trigger, reservierte Kapazität und andere erweiterte Funktionen, um Ihre DynamoDB-Nutzung zu verbessern.

Die DynamoDB-Konsole bietet eine umfassende Oberfläche für die Verwaltung Ihrer DynamoDB-Ressourcen. Wir empfehlen Ihnen, auf die Konsole zuzugreifen und mit ihr zu interagieren, um mehr zu erfahren.

## Mit dem AWS CLI
<a name="Tools.CLI"></a>

 Sie können die AWS Command Line Interface (AWS CLI) verwenden, um mehrere AWS Dienste von der Befehlszeile aus zu steuern und sie mithilfe von Skripten zu automatisieren. Sie können das AWS CLI für Ad-hoc-Operationen verwenden, z. B. das Erstellen einer Tabelle. Sie können damit auch Amazon-DynamoDB-Operationen in Hilfsprogrammskripts einbetten.

 Bevor Sie das AWS CLI mit DynamoDB verwenden können, benötigen Sie eine Zugriffsschlüssel-ID und einen geheimen Zugriffsschlüssel. Weitere Informationen finden Sie unter [Erteilen programmgesteuerten Zugriffs](SettingUp.DynamoWebService.md#SettingUp.DynamoWebService.GetCredentials). 

Eine vollständige Liste aller Befehle, die für DynamoDB in verfügbar sind AWS CLI, finden Sie in der [AWS CLI Befehlsreferenz](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/index.html).

**Topics**

### Herunterladen und Konfigurieren der AWS CLI
<a name="Tools.CLI.DownloadingAndRunning"></a>

Das AWS CLI ist unter [http://aws.amazon.com/cli](https://aws.amazon.com/cli) verfügbar. Sie kann auf Windows, macOS oder Linux ausgeführt werden. Gehen Sie nach dem Herunterladen wie folgt vor AWS CLI, um es zu installieren und zu konfigurieren:

1. Rufen Sie auf das [AWS Command Line Interface -Benutzerhandbuch](https://docs.aws.amazon.com/cli/latest/userguide/) auf.

1. Befolgen Sie die Anweisungen unter [Installieren der AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) und [Konfigurieren der AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).

### Verwenden von AWS CLI mit DynamoDB
<a name="Tools.CLI.UsingWithDDB"></a>

Das Befehlszeilenformat besteht aus einem DynamoDB-Operationsnamen gefolgt von den Parametern für diese Operation. Das AWS CLI unterstützt eine Kurzsyntax für die Parameterwerte sowie JSON.

Mit dem folgenden Befehl wird beispielsweise eine Tabelle namens *Musik* erstellt. Der Partitionsschlüssel ist *Artist* und der Sortierschlüssel ist. *SongTitle* (Für eine bessere Lesbarkeit werden lange Befehle in diesem Abschnitt über mehrere Zeilen verteilt.)

```
aws dynamodb create-table \
    --table-name Music \
    --attribute-definitions \
        AttributeName=Artist,AttributeType=S \
        AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --billing-mode PAY_PER_REQUEST \
    --table-class STANDARD
```

Mit den folgenden Befehlen werden der Tabelle neue Elemente hinzugefügt. Diese Beispiele verwenden eine Kombination von Syntax-Kurznotation und JSON.

```
aws dynamodb put-item \
    --table-name Music \
    --item \
        '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}}' \
    --return-consumed-capacity TOTAL

aws dynamodb put-item \
    --table-name Music \
    --item '{
        "Artist": {"S": "Acme Band"},
        "SongTitle": {"S": "Happy Day"},
        "AlbumTitle": {"S": "Songs About Life"} }' \
    --return-consumed-capacity TOTAL
```

Es ist nicht einfach, in der Befehlszeile gültigen JSON-Code zu erstellen. Die AWS CLI kann aber JSON-Dateien lesen. Betrachten Sie dazu das folgende Beispiel für einen JSON-Codeausschnitt, der in einer Datei mit dem Namen *key-conditions.json* gespeichert ist:

```
{
    "Artist": {
        "AttributeValueList": [
            {
                "S": "No One You Know"
            }
        ],
        "ComparisonOperator": "EQ"
    },
    "SongTitle": {
        "AttributeValueList": [
            {
                "S": "Call Me Today"
            }
        ],
        "ComparisonOperator": "EQ"
    }
}
```

Sie können jetzt eine `Query`-Anforderung über die AWS CLI ausgeben. In diesem Beispiel werden die Inhalte der Datei *key-conditions.json* für den Parameter `--key-conditions` verwendet:

```
aws dynamodb query --table-name Music --key-conditions file://key-conditions.json
```

### Verwenden von AWS CLI mit DynamoDB local
<a name="Tools.CLI.UsingWithDDBLocal"></a>

 AWS CLI Sie können auch mit DynamoDB Local (herunterladbare Version) interagieren, die auf Ihrem Computer läuft. Um diese Funktion zu aktivieren, fügen Sie jedem Befehl den folgenden Parameter hinzu:

`--endpoint-url http://localhost:8000`

Das folgende Beispiel verwendet die AWS CLI , um die Tabellen in einer lokalen Datenbank aufzulisten.

```
aws dynamodb list-tables --endpoint-url http://localhost:8000
```

Wenn DynamoDB eine andere Portnummer verwendet als den Standardport (8000), ändern Sie den `--endpoint-url` Wert entsprechend.

**Anmerkung**  
Die lokale DynamoDB-Version (herunterladbare Version) AWS CLI kann nicht als Standardendpunkt verwendet werden. Daher müssen Sie mit jedem Befehl `--endpoint-url` angeben. 

## Verwenden der API
<a name="Using.API"></a>

 Sie können die AWS-Managementkonsole und die verwenden AWS Command Line Interface , um interaktiv mit Amazon DynamoDB zu arbeiten. Um DynamoDB jedoch optimal zu nutzen, können Sie Anwendungscode mit dem schreiben. AWS SDKs

 AWS SDKs Sie bieten umfassende Unterstützung für DynamoDB in [Java](https://aws.amazon.com/sdk-for-java), [JavaScript im Browser](https://aws.amazon.com/sdk-for-browser), [.NET](https://aws.amazon.com/sdk-for-net), [Node.js](https://aws.amazon.com/sdk-for-node-js), [PHP](https://aws.amazon.com/sdk-for-php), [Python](https://aws.amazon.com/sdk-for-python), [Ruby](https://aws.amazon.com/sdk-for-ruby), [C\$1\$1](https://aws.amazon.com/sdk-for-cpp), [Go](https://aws.amazon.com/sdk-for-go), [Android](https://aws.amazon.com/mobile/sdk/) und [iOS](https://aws.amazon.com/mobile/sdk/).

Bevor Sie das AWS SDKs mit DynamoDB verwenden können, benötigen Sie eine AWS Zugriffsschlüssel-ID und einen geheimen Zugriffsschlüssel. Weitere Informationen finden Sie unter [Einrichten von DynamoDB (Webservice)](SettingUp.DynamoWebService.md). 

 Einen allgemeinen Überblick über die DynamoDB-Anwendungsprogrammierung mit dem finden Sie AWS SDKs unter. [Programmieren mit DynamoDB und AWS SDKs](Programming.md) 

## Verwenden von NoSQL-Workbench für DynamoDB
<a name="Using.Workbench"></a>

Sie können auch die [NoSQL-Workbench für DynamoDB](workbench.md) herunterladen und verwenden, um auf DynamoDB zuzugreifen.

NoSQL Workbench for Amazon DynamoDB ist eine plattformübergreifende clientseitige GUI-Anwendung für moderne Datenbankentwicklung und -operationen. Sie ist für Windows, macOS und Linux verfügbar. NoSQL Workbench ist ein visuelles Entwicklungstool, das Funktionen zur Datenmodellierung, Datenvisualisierung und Abfrageentwicklung bereitstellt, mit denen Sie DynamoDB-Tabellen entwerfen, erstellen, abfragen und verwalten können. NoSQL Workbench enthält jetzt die lokale Version von DynamoDB als optionalen Bestandteil des Installationsprozesses. Dies macht es einfacher, Ihre Daten in die lokale Version von DynamoDB zu modellieren. Weitere Informationen über die lokale Version von DynamoDB und ihre Anforderungen finden Sie unter [Lokale Einrichtung von DynamoDB (herunterladbare Version)](DynamoDBLocal.md).

**Anmerkung**  
Die NoSQL Workbench für DynamoDB unterstützt derzeit keine AWS Anmeldungen, die mit Zwei-Faktor-Authentifizierung (2FA) konfiguriert sind.

**Datenmodellierung**  
Mit NoSQL-Workbench für DynamoDB können Sie neue Datenmodelle aus vorhandenen Datenmodellen erstellen oder Modelle basierend auf vorhandenen Datenmodellen entwerfen, die den Datenzugriffsmustern Ihrer Anwendung entsprechen. Sie können das gestaltete Datenmodell am Ende des Prozesses auch importieren und exportieren. Weitere Informationen finden Sie unter [Erstellen von Datenmodellen mit NoSQL Workbench](workbench.Modeler.md).

**Erstellen von Operationen**  
NoSQL Workbench stellt eine umfassende Grafikbenutzeroberfläche für die Entwicklung und den Test von Abfragen bereit. Sie können den *Operation Builder* verwenden, um Live-Datensätze anzuzeigen, zu erkunden und abzufragen. Sie können auch den strukturieren Operation Builder verwenden, um Datenebenen-Operationen zu erstellen und durchzuführen. Er unterstützt Projektions- und Konditionsausdrücke und ermöglicht das Generieren von Beispielcode in mehreren Sprachen. Weitere Informationen finden Sie unter [Erkunden von Datasets und Erstellen von Vorgängen mit NoSQL Workbench](workbench.querybuilder.md).

## IP-Adressbereiche
<a name="Using.IPRanges"></a>

Amazon Web Services (AWS) veröffentlicht seine aktuellen IP-Adressbereiche im JSON-Format. Laden Sie die Datei [ip-ranges.json](https://ip-ranges.amazonaws.com/ip-ranges.json) herunter, um die aktuellen Bereiche anzuzeigen. Weitere Informationen finden Sie unter [AWS IP-Adressbereiche](https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html) im Allgemeine AWS-Referenz.

Um die IP-Adressbereiche zu suchen, die Sie verwenden können, um auf die [DynamoDB-Tabellen und Indizes zuzugreifen](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Operations_Amazon_DynamoDB.html), suchen Sie in der Datei "ip-ranges.json" nach folgender Zeichenfolge: `"service": "DYNAMODB"`.

**Anmerkung**  
Die IP-Adressbereiche gelten nicht für DynamoDB Streams oder DynamoDB Accelerator (DAX). 

## Dual-Stack-Endpunkte für Internet Protocol Version 6 () IPv6
<a name="dual-stackipv4-6"></a>

DynamoDB bietet Dual-Stack-Endpunkte, die sowohl mit als auch kompatibel sind. IPv4 IPv6 Die Benennungskonventionen für Endpunkte lauten wie folgt:
+ `dynamodb.<region>.api.aws`
+ `<account-id>.ddb.<region>.api.aws`
+ `streams-dynamodb.<region>.api.aws`
+ `dax.<region>.api.aws`
+ `dynamodb-fips.<region>.api.aws`

*Eine vollständige Liste der DynamoDB-Endpunkte und der regionalen Verfügbarkeit finden Sie im Thema [Amazon DynamoDB DynamoDB-Endpunkte und Kontingente](https://docs.aws.amazon.com/general/latest/gr/ddb.html) im Allgemeinen Referenzhandbuch.AWS *

Weitere Informationen zur Einrichtung der AWS CLI für die Verwendung von Dual-Stack-Endpunkten finden Sie im Abschnitt [Zur Verwendung von Dual-Stack-Endpunkten für alle AWS Dienste einrichten](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-endpoints.html#endpoints-dual-stack) im Leitfaden zur *AWS Befehlszeilenschnittstelle*.

*Weitere Informationen zur Einrichtung Ihrer SDK-Clients für die Verwendung von Dual-Stack-Endpunkten finden Sie unter dem Thema [Dual-Stack- und FIPS-Endpunkte im Handbuch und Tools](https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoints.html).AWS SDKs *

Bevor Sie DynamoDB mit verwenden IPv6, müssen Sie Ihre IAM-Benutzerrolle oder die ressourcenbasierten Richtlinien, die Sie für die IP-Adressfilterung verwenden, aktualisieren, um Adressbereiche einzubeziehen. IPv6 IP-Adressfilterrichtlinien, die Adressen nicht berücksichtigen, können zu IPv6 Zugriffsproblemen führen. Weitere Informationen finden Sie im Abschnitt [Operatoren für IP-Adressbedingungen](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_IPAddress) im *Handbuch AWS Identity and Access Management*.

## Voraussetzungen
<a name="GettingStarted.SettingUp.DynamoWebService"></a>

Machen Sie sich vor dem Start des Amazon-DynamoDB-Tutorials damit vertraut, wie Sie in [Zugreifen auf DynamoDB](AccessingDynamoDB.md) auf DynamoDB zugreifen können. Richten Sie DynamoDB anschließend entweder über den Webservice oder die lokal heruntergeladene Version in [Einrichten von DynamoDB](SettingUp.md) ein. Fahren Sie danach fort mit [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md).

**Anmerkung**  
Wenn Sie nur über den mit DynamoDB interagieren möchten AWS-Managementkonsole, benötigen Sie keinen AWS Zugriffsschlüssel. Führen Sie die Schritte unter [Registrierung für AWS aus](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SettingUp.DynamoWebService.html#SettingUp.DynamoWebService.SignUpForAWS) und fahren Sie dann fort mit. [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md)
Wenn Sie sich nicht für ein Konto mit kostenlosem Kontingent registrieren möchten, können Sie [die lokale Version von DynamoDB (herunterladbare Version)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) einrichten. Fahren Sie dann mit [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md) fort. 
Bei der Arbeit mit CLI-Befehlen in Terminals unter Linux und unter Windows gibt es Unterschiede. Die folgende Anleitung enthält Befehle, die für Linux-Terminals (einschließlich macOS) formatiert sind, sowie Befehle, die für Windows CMD formatiert sind. Wählen Sie den Befehl, der am besten zu der von Ihnen verwendeten Terminalanwendung passt. 

# Einrichten von DynamoDB
<a name="SettingUp"></a>

 AWS Bietet zusätzlich zum Amazon DynamoDB DynamoDB-Webservice eine herunterladbare Version von DynamoDB, die Sie auf Ihrem Computer ausführen können. Die herunterladbare Version ist nützlich für die Entwicklung und das Testen Ihres Codes. Damit können Sie Anwendungen ohne Zugriff auf den DynamoDB-Webservice lokal entwickeln und testen. 

 Die Themen in diesem Abschnitt beschreiben, wie Sie DynamoDB (herunterladbare Version) und den DynamoDB-Webservice einrichten. 

**Topics**
+ [Einrichten von DynamoDB (Webservice)](SettingUp.DynamoWebService.md)
+ [Lokale Einrichtung von DynamoDB (herunterladbare Version)](DynamoDBLocal.md)

# Einrichten von DynamoDB (Webservice)
<a name="SettingUp.DynamoWebService"></a>

 So verwenden Sie den Amazon-DynamoDB-Webservice: 

1.  [Registrieren für AWS.](#SettingUp.DynamoWebService.SignUpForAWS) 

1.  [Rufen Sie einen AWS Zugriffsschlüssel](#SettingUp.DynamoWebService.GetCredentials) ab (wird verwendet, um programmgesteuert auf DynamoDB zuzugreifen). 
**Anmerkung**  
 Wenn Sie planen, nur über den mit DynamoDB zu interagieren AWS-Managementkonsole, benötigen Sie keinen AWS Zugriffsschlüssel, und Sie können direkt zu. [Verwenden der Konsole](AccessingDynamoDB.md#ConsoleDynamoDB) 

1.  [Konfigurieren der Anmeldeinformationen](#SettingUp.DynamoWebService.ConfigureCredentials) (für den programmgesteuerten Zugriff auf DynamoDB). 

## Melden Sie sich an für AWS
<a name="SettingUp.DynamoWebService.SignUpForAWS"></a>

 Um den DynamoDB-Dienst nutzen zu können, benötigen Sie ein AWS Konto. Wenn Sie noch kein Konto besitzen, werden Sie bei der Anmeldung aufgefordert, eines zu erstellen. Für AWS Dienste, für die Sie sich registrieren, werden Ihnen keine Gebühren berechnet, es sei denn, Sie nutzen sie. 

**Um sich anzumelden für AWS**

1. Öffnen Sie [https://portal.aws.amazon.com/billing/die Anmeldung.](https://portal.aws.amazon.com/billing/signup)

1. Folgen Sie den Online-Anweisungen.

   Während der Anmeldung erhalten Sie einen Telefonanruf oder eine Textnachricht und müssen einen Verifizierungscode über die Telefontasten eingeben.

   Wenn Sie sich für eine anmelden AWS-Konto, *Root-Benutzer des AWS-Kontos*wird eine erstellt. Der Root-Benutzer hat Zugriff auf alle AWS-Services und Ressourcen des Kontos. Als bewährte Sicherheitsmethode weisen Sie einem Benutzer Administratorzugriff zu und verwenden Sie nur den Root-Benutzer, um [Aufgaben auszuführen, die Root-Benutzerzugriff erfordern](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks).

## Erteilen programmgesteuerten Zugriffs
<a name="SettingUp.DynamoWebService.GetCredentials"></a>

 Bevor Sie programmgesteuert oder über AWS Command Line Interface (AWS CLI) auf DynamoDB zugreifen können, benötigen Sie programmatischen Zugriff. Sie benötigen keinen programmgesteuerten Zugriff, wenn Sie nur die DynamoDB-Konsole verwenden möchten. 

Benutzer benötigen programmatischen Zugriff, wenn sie mit außerhalb von interagieren möchten. AWS AWS-Managementkonsole Die Art und Weise, wie programmatischer Zugriff gewährt wird, hängt von der Art des Benutzers ab, der zugreift. AWS

Um Benutzern programmgesteuerten Zugriff zu gewähren, wählen Sie eine der folgenden Optionen.


****  

| Welcher Benutzer benötigt programmgesteuerten Zugriff? | Bis | Von | 
| --- | --- | --- | 
| IAM | (Empfohlen) Verwenden Sie Konsolenanmeldeinformationen als temporäre Anmeldeinformationen, um programmatische Anfragen an AWS CLI AWS SDKs, oder zu signieren. AWS APIs |  Befolgen Sie die Anweisungen für die Schnittstelle, die Sie verwenden möchten. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/SettingUp.DynamoWebService.html)  | 
|  Mitarbeiteridentität (Benutzer, die in IAM Identity Center verwaltet werden)  | Verwenden Sie temporäre Anmeldeinformationen, um programmatische Anfragen an das AWS CLI AWS SDKs, oder AWS APIs zu signieren. |  Befolgen Sie die Anweisungen für die Schnittstelle, die Sie verwenden möchten. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/SettingUp.DynamoWebService.html)  | 
| IAM | Verwenden Sie temporäre Anmeldeinformationen, um programmatische Anfragen an das AWS CLI AWS SDKs, oder zu signieren. AWS APIs | Folgen Sie den Anweisungen unter [Verwenden temporärer Anmeldeinformationen mit AWS Ressourcen](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html) im IAM-Benutzerhandbuch. | 
| IAM | (Nicht empfohlen)Verwenden Sie langfristige Anmeldeinformationen, um programmatische Anfragen an das AWS CLI AWS SDKs, oder zu signieren. AWS APIs |  Befolgen Sie die Anweisungen für die Schnittstelle, die Sie verwenden möchten. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/SettingUp.DynamoWebService.html)  | 

## Konfigurieren der Anmeldeinformationen
<a name="SettingUp.DynamoWebService.ConfigureCredentials"></a>

 Bevor Sie programmgesteuert oder über die auf DynamoDB zugreifen können, müssen Sie Ihre Anmeldeinformationen so konfigurieren AWS CLI, dass die Autorisierung für Ihre Anwendungen aktiviert wird. 

 Dazu stehen verschiedene Möglichkeiten zur Verfügung. Beispielsweise können Sie die Datei mit den Anmeldeinformationen zum Speichern Ihrer Zugriffsschlüssel-ID und des geheimen Zugriffsschlüssels manuell erstellen. Sie können den AWS CLI Befehl auch verwenden, um die Datei automatisch `aws configure` zu erstellen. Alternativ können Sie Umgebungsvariablen verwenden. Weitere Informationen zur Konfiguration Ihrer Anmeldeinformationen finden Sie im entwicklerspezifischen AWS SDK-Entwicklerhandbuch.

 Informationen zur Installation und Konfiguration von finden Sie AWS CLI unter. [Mit dem AWS CLI](AccessingDynamoDB.md#Tools.CLI) 

## Integration mit anderen DynamoDB-Services
<a name="w2aab9c17b9c13"></a>

Sie können DynamoDB in viele andere AWS Dienste integrieren. Weitere Informationen finden Sie hier: 
+ [DynamoDB mit anderen Diensten verwenden AWS](OtherServices.md)
+ [CloudFormation für DynamoDB](https://docs.aws.amazon.com//AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html)
+ [Verwendung von AWS Backup mit DynamoDB](backuprestore_HowItWorksAWS.md)
+ [AWS Identity and Access Management (IAM) und DynamoDB](identity-and-access-mgmt.md)
+ [Verwendung AWS Lambda mit Amazon DynamoDB](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html)

# Lokale Einrichtung von DynamoDB (herunterladbare Version)
<a name="DynamoDBLocal"></a>

 Mit der herunterladbaren Version von Amazon DynamoDB können Sie Anwendungen entwickeln und testen, ohne auf den DynamoDB-Webservice zuzugreifen. Die Datenbank wird stattdessen als unabhängige Komponente auf Ihrem Computer ausgeführt. Wenn Sie bereit sind, Ihre Anwendung in der Produktion bereitzustellen, entfernen Sie den lokalen Endpunkt im Code. Er verweist dann auf den DynamoDB-Webservice. 

 Mit dieser lokalen Version sind Einsparungen im Hinblick auf den Durchsatz, die Datenspeicherung und Datenübertragungsgebühren möglich. Darüber hinaus benötigen Sie für die Entwicklung der Anwendung keine Internetverbindung. 

 Die lokale Version von DynamoDB ist als [Download](DynamoDBLocal.DownloadingAndRunning.md#DynamoDBLocal.DownloadingAndRunning.title) (erfordert JRE), als [Apache-Maven-Abhängigkeit](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html#apache-maven) oder als [Docker-Image](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html#docker) verfügbar. 

 Wenn Sie stattdessen den Amazon-DynamoDB-Webservice verwenden möchten, finden Sie unter [Einrichten von DynamoDB (Webservice)](SettingUp.DynamoWebService.md) weitere Informationen. 

**Topics**
+ [Bereitstellen der lokalen Version von DynamoDB auf Ihrem Computer](DynamoDBLocal.DownloadingAndRunning.md)
+ [DynamoDB-Local-Nutzungshinweise](DynamoDBLocal.UsageNotes.md)
+ [Versionsverlauf für die lokale Version von DynamoDB](DynamoDBLocalHistory.md)
+ [Telemetrie in der lokalen Version von DynamoDB](DynamoDBLocalTelemetry.md)

# Bereitstellen der lokalen Version von DynamoDB auf Ihrem Computer
<a name="DynamoDBLocal.DownloadingAndRunning"></a>

**Anmerkung**  
Die lokale Version von DynamoDB ist in drei Versionen verfügbar: v3.x (aktuell), v2.x (Legacy) und v1.x (veraltet).
DynamoDB v3.x wird für Ihre lokalen Test- und Entwicklungszwecke empfohlen.
Die Migration der lokalen Version von DynamoDB V2.x auf V3.x erfordert die Aktualisierung der Importanweisungen von `com.amazonaws.services.dynamodbv2` auf `software.amazon.dynamodb` und die Aktualisierung der Maven-Abhängigkeiten für Maven-Benutzer.
Wenn Sie eine Anwendung zum SDK für Java 2.x migrieren, die das SDK für Java v1.x verwendet, folgen Sie den Schritten unter [AWS -SDK für Java 2.x](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration.html).

## Herunterladen der lokalen Version von DynamoDB
<a name="DynamoDBLocal.DownloadingAndRunning.V2"></a>

Gehen Sie wie folgt vor, um DynamoDB einzurichten und auf Ihrem Computer auszuführen.

**So richten Sie DynamoDB auf dem Computer ein**

1. Laden Sie die lokale Version von DynamoDB kostenlos von einem der folgenden Speicherorte herunter.  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html)
**Wichtig**  
 Um DynamoDB v2.6.0 oder höher auf Ihrem Computer ausführen zu können, benötigen Sie die Java Runtime Environment (JRE) Version 17.x oder neuer. Die Anwendung kann nicht unter früheren JRE-Versionen ausgeführt werden.

1.  Nachdem Sie das Archiv heruntergeladen haben, extrahieren Sie die Inhalte und kopieren Sie das entpackte Verzeichnis an einen Speicherort Ihrer Wahl. 

1.  Zum Starten von DynamoDB auf Ihrem Computer, öffnen Sie ein Befehlszeilenfenster, gehen Sie zu dem Verzeichnis, in das Sie `DynamoDBLocal.jar` extrahiert haben, und geben Sie den folgenden Befehl ein. 

   ```
   java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
   ```
**Anmerkung**  
 Wenn Sie Windows verwenden, achten Sie darauf PowerShell, den Parameternamen oder den gesamten Namen und Wert wie folgt einzuschließen:   
 ` java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar `   
 DynamoDB verarbeitet eingehende Anforderungen, bis Sie den Service beenden. Zum Beenden von DynamoDB geben Sie Strg\$1C in die Befehlszeile ein.   
 DynamoDB verwendet standardmäßig Port 8000. Wenn Port 8000 nicht verfügbar ist, wird eine Ausnahme ausgelöst. Um eine vollständige Liste der DynamoDB-Laufzeitoptionen, einschließlich `-port`, zu erhalten, geben Sie folgenden Befehl ein.   
 ` java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help ` 

1. Bevor Sie programmgesteuert oder über die AWS Command Line Interface (AWS CLI) auf DynamoDB zugreifen können, müssen Sie die Anmeldeinformationen so konfigurieren, dass die Autorisierung für die Anwendungen aktiviert wird. Die herunterladbare Version von DynamoDB benötigt Anmeldeinformationen, um arbeiten zu können, wie in dem folgenden Beispiel gezeigt. 

   ```
   AWS Access Key ID: "fakeMyKeyId"
   AWS Secret Access Key: "fakeSecretAccessKey"
   Default Region Name: "fakeRegion"
   ```

    Sie können die Anmeldeinformationen mit dem  AWS CLI -Befehl `aws configure` einrichten. Weitere Informationen finden Sie unter [Mit dem AWS CLI](AccessingDynamoDB.md#Tools.CLI). 

1.  Beginnen Sie mit dem Schreiben von Anwendungen. Verwenden Sie den Parameter, um auf DynamoDB zuzugreifen AWS CLI, das lokal mit dem ausgeführt wird`--endpoint-url `. Sie können z. B. den folgenden Befehl verwenden, um DynamoDB-Tabellen aufzulisten. 

   ```
   aws dynamodb list-tables --endpoint-url http://localhost:8000
   ```

## Ausführen der lokalen Version von DynamoDB als Docker-Image
<a name="DynamoDBLocal.DownloadingAndRunning.Docker"></a>

 Die herunterladbare Version von Amazon DynamoDB ist als Docker-Image verfügbar. Weitere Informationen finden Sie unter [dynamodb-local](https://hub.docker.com/r/amazon/dynamodb-local). Geben Sie folgenden Befehl ein, um Ihre aktuelle lokale Version von DynamoDB zu sehen:

```
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -version
```

 Ein Beispiel für die Verwendung von DynamoDB local als Teil einer REST-Anwendung, die auf der AWS Serverless Application Model (AWS SAM) aufbaut, finden Sie unter [SAM DynamoDB-Anwendung](https://github.com/aws-samples/aws-sam-java-rest) zur Verwaltung von Bestellungen. Diese Beispielanwendung demonstriert die Verwendung der lokalen Version von DynamoDB für Testzwecke. 

 Wenn Sie eine Anwendung mit mehreren Containern ausführen möchten, die auch den lokalen DynamoDB-Container nutzt, verwenden Sie Docker Compose, um alle Services in Ihrer Anwendung zu definieren und auszuführen, einschließlich DynamoDB lokal. 

**So gehen Sie vor, um DynamoDB zu installieren und lokal auszuführen:**

1.  Führen Sie Download und Installation von [Docker Desktop](https://www.docker.com/products/docker-desktop) durch. 

1.  Kopieren Sie den folgenden Code in eine Datei, und speichern Sie ihn unter `docker-compose.yml`. 

   ```
   services:
    dynamodb-local:
      command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
      image: "amazon/dynamodb-local:latest"
      container_name: dynamodb-local
      ports:
        - "8000:8000"
      volumes:
        - "./docker/dynamodb:/home/dynamodblocal/data"
      working_dir: /home/dynamodblocal
   ```

    Wenn sich Ihre Anwendung und DynamoDB lokal in separaten Containern befinden sollen, verwenden Sie die folgende YAML-Datei: 

   ```
   version: '3.8'
   services:
    dynamodb-local:
      command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
      image: "amazon/dynamodb-local:latest"
      container_name: dynamodb-local
      ports:
        - "8000:8000"
      volumes:
        - "./docker/dynamodb:/home/dynamodblocal/data"
      working_dir: /home/dynamodblocal
    app-node:
      depends_on:
        - dynamodb-local
      image: amazon/aws-cli
      container_name: app-node
      ports:
       - "8080:8080"
      environment:
        AWS_ACCESS_KEY_ID: 'DUMMYIDEXAMPLE'
        AWS_SECRET_ACCESS_KEY: 'DUMMYEXAMPLEKEY'
      command:
        dynamodb describe-limits --endpoint-url http://dynamodb-local:8000 --region us-west-2
   ```

    Dieses docker-compose.yml-Skript erstellt einen `app-node`-Container und einen `dynamodb-local`-Container. Das Skript führt einen Befehl im Container `app-node` aus, der mithilfe der AWS CLI eine Verbindung mit dem `dynamodb-local`-Container herstellt und die Konten- und Tabellenlimits beschreibt. 

    Wenn Sie diesen Vorgang bei Ihrem eigenen Anwendungsimage verwenden möchten, ersetzen Sie den Wert `image` im folgenden Beispiel durch den Wert Ihrer Anwendung. 

   ```
   version: '3.8'
   services:
    dynamodb-local:
      command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
      image: "amazon/dynamodb-local:latest"
      container_name: dynamodb-local
      ports:
        - "8000:8000"
      volumes:
        - "./docker/dynamodb:/home/dynamodblocal/data"
      working_dir: /home/dynamodblocal
    app-node:
      image: location-of-your-dynamodb-demo-app:latest
      container_name: app-node
      ports:
        - "8080:8080"
      depends_on:
        - "dynamodb-local"
      links:
        - "dynamodb-local"
      environment:
        AWS_ACCESS_KEY_ID: 'DUMMYIDEXAMPLE'
        AWS_SECRET_ACCESS_KEY: 'DUMMYEXAMPLEKEY'
        REGION: 'eu-west-1'
   ```
**Anmerkung**  
 Die YAML-Skripts erfordern, dass Sie einen AWS Zugriffsschlüssel und einen AWS geheimen Schlüssel angeben, aber es müssen keine gültigen AWS Schlüssel sein, damit Sie lokal auf DynamoDB zugreifen können. 

1.  Führen Sie die folgende Befehlzeilen-Befehle aus: 

   ```
   docker-compose up
   ```

## Ausführen der lokalen Version von DynamoDB als Apache Maven-Abhängigkeit
<a name="DynamoDBLocal.DownloadingAndRunning.Maven.v2"></a>

**Anmerkung**  
Wenn Sie eine Anwendung zum SDK für Java 2.x migrieren, die das SDK für Java v1.x verwendet, folgen Sie den Schritten unter [AWS -SDK für Java 2.x](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration.html).

 Führen Sie die folgenden Schritte aus, um Amazon DynamoDB in Ihrer Anwendung als Abhängigkeit zu verwenden. 

**So stellen Sie DynamoDB als Apache-Maven-Repository bereit**

1.  Laden Sie Apache Maven herunter und installieren Sie es. Weitere Informationen finden Sie unter [Downloading Apache Maven](https://maven.apache.org/download.cgi) und [Installing Apache Maven](https://maven.apache.org/install.html). 

1.  Fügen Sie das DynamoDB-Maven-Repository zur POM-Datei (Project Object Model) Ihrer Anwendung hinzu. 

   ```
   <!--Dependency:-->
   <dependencies>
      <dependency>
         <groupId>software.amazon.dynamodb</groupId>
         <artifactId>DynamoDBLocal</artifactId>
         <version>3.3.0</version>
      </dependency>
   </dependencies>
   ```

    Beispielvorlage zur Verwendung mit Spring Boot 3 and/or Spring Framework 6: 

   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   
   <groupId>org.example</groupId>
   <artifactId>SpringMavenDynamoDB</artifactId>
   <version>1.0-SNAPSHOT</version>
   
   <properties>
      <spring-boot.version>3.0.1</spring-boot.version>
      <maven.compiler.source>17</maven.compiler.source>
      <maven.compiler.target>17</maven.compiler.target>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   
      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>3.1.0</version>
      </parent>
   
   <dependencies>
      <dependency>
          <groupId>software.amazon.dynamodb</groupId>
          <artifactId>DynamoDBLocal</artifactId>
          <version>3.3.0</version>
      </dependency>
      <!-- Spring Boot -->
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter</artifactId>
          <version>${spring-boot.version}</version>
      </dependency>
      <!-- Spring Web -->
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
          <version>${spring-boot.version}</version>
      </dependency>
      <!-- Spring Data JPA -->
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
          <version>${spring-boot.version}</version>
      </dependency>
      <!-- Other Spring dependencies -->
      <!-- Replace the version numbers with the desired version -->
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>6.0.0</version>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>6.0.0</version>
      </dependency>
      <!-- Add other Spring dependencies as needed -->
      <!-- Add any other dependencies your project requires -->
   </dependencies>
   </project>
   ```
**Anmerkung**  
 Sie können auch die URL des [Maven Central Repository](https://mvnrepository.com/artifact/com.amazonaws/DynamoDBLocal?repo=dynamodb-local-release) verwenden. 

## Führen Sie DynamoDB lokal aus in AWS CloudShell
<a name="DynamoDBLocal.DynamoDB.Local.CloudShell"></a>

AWS CloudShell ist eine browserbasierte, vorauthentifizierte Shell, die Sie direkt von der aus starten können. AWS-Managementkonsole Sie können auf verschiedene Arten AWS CloudShell zu ihr navigieren. AWS-Managementkonsole Weitere Informationen finden Sie unter [Erste Schritte mit AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/getting-started.html).

Gehen Sie wie folgt vor, um DynamoDB lokal an Ihrem AWS CloudShell beliebigen Ort in der auszuführen. AWS-Managementkonsole

**Um DynamoDB lokal in Ihrem AWS CloudShell auszuführen AWS-Managementkonsole**

1. Starten Sie AWS CloudShell von der Konsolenoberfläche aus, wählen Sie eine verfügbare AWS-Region aus und wechseln Sie zu Ihrer bevorzugten Shell, z. B. Bash oder PowerShell Z-Shell.

1. Um eine auszuwählen AWS-Region, gehen **Sie zum Menü „Region auswählen**“ und wählen Sie eine [unterstützte AWS-Region](https://docs.aws.amazon.com/cloudshell/latest/userguide/supported-aws-regions.html) aus. (Verfügbare Regionen sind hervorgehoben.)

1. Starten Sie von der aus AWS-Managementkonsole, AWS CloudShell indem Sie eine der folgenden Optionen wählen:

   1. Klicken Sie in der Navigationsleiste auf das **AWS CloudShell**-Symbol.

   1. Geben Sie das Wort in das **Suchfeld** ein CloudShell, und wählen Sie dann **CloudShell**.

   1. Wählen Sie im Widget „**Zuletzt besucht**“ **CloudShell**.

   1. Wählen Sie in der Werkzeugleiste der Konsole **CloudShell**.

1. Um DynamoDB lokal in auszuführen, können AWS CloudShell Sie den `dynamodb-local` Alias verwenden. Sie können zusätzliche Befehlszeilenoptionen zum Ändern der Einstellungen Ihrer lokalen Version von DynamoDB angeben. Die verfügbaren Optionen finden Sie unter [DynamoDB-Local-Nutzungshinweise](DynamoDBLocal.UsageNotes.md).
**Anmerkung**  
Um DynamoDB local im Hintergrund auszuführen, führen Sie DynamoDB local mit: aus. AWS CloudShell `dynamodb-local &`

1. Verwenden Sie den Parameter, um auf DynamoDB zuzugreifen AWS CLI, das lokal AWS CloudShell mit dem ausgeführt wird`--endpoint-url`. Sie können z. B. den folgenden Befehl verwenden, um DynamoDB-Tabellen aufzulisten:

   `aws dynamodb list-tables --endpoint-url http://localhost:8000`

Ein Beispielprojekt, das verschiedene Ansätze zur Einrichtung und Nutzung der lokalen Version von DynamoDB zeigt – darunter das Herunterladen von JAR-Dateien, die Ausführung als Docker-Image und die Einbindung als Maven-Abhängigkeit – finden Sie unter [Java-Beispielprojekt für die lokale Version von DynamoDB](https://github.com/awslabs/amazon-dynamodb-local-samples/tree/main).

# DynamoDB-Local-Nutzungshinweise
<a name="DynamoDBLocal.UsageNotes"></a>

 Mit Ausnahme des Endpunkts sollten Anwendungen, die mit der herunterladbaren Version von Amazon DynamoDB ausgeführt werden, auch mit dem DynamoDB-Webservice funktionieren. Bei der lokalen Verwendung von DynamoDB sollten Sie allerdings Folgendes beachten: 
+  *Wenn Sie die `-sharedDb` Option verwenden, erstellt DynamoDB eine einzelne Datenbankdatei mit dem Namen shared-local-instance .db.* Jedes Programm, das eine Verbindung mit DynamoDB herstellt, greift auf diese Datei zu. Wenn Sie die Datei löschen, gehen alle darin gespeicherten Daten verloren. 
+  Wenn Sie diese Option weglassen`-sharedDb`, erhält die Datenbankdatei den Namen *myaccesskeyid\$1region.db* mit der AWS Zugriffsschlüssel-ID und AWS Region, wie sie in Ihrer Anwendungskonfiguration erscheinen. Wenn Sie die Datei löschen, gehen alle darin gespeicherten Daten verloren. 
+  Bei Verwendung der `-inMemory`-Option schreibt DynamoDB keine Datenbankdateien. Stattdessen werden alle Daten im Arbeitsspeicher abgelegt und beim Beenden von DynamoDB nicht gespeichert. 
+  Wenn Sie die `-inMemory`-Option verwenden, ist die `-sharedDb`-Option ebenfalls erforderlich. 
+  Bei Verwendung der Option `-optimizeDbBeforeStartup` müssen Sie auch den `-dbPath`-Parameter angeben, damit DynamoDB die entsprechende Datenbankdatei finden kann. 
+  Die AWS SDKs für DynamoDB erfordern, dass Ihre Anwendungskonfiguration einen Zugriffsschlüsselwert und einen AWS Regionswert angibt. DynamoDB verwendet diese Werte, um die lokale Datenbankdatei zu benennen, sofern Sie nicht die Option `-sharedDb` oder `-inMemory` verwenden. Diese Werte müssen keine gültigen AWS Werte sein, um lokal ausgeführt zu werden. Möglicherweise ist es jedoch komfortabler, gültige Werte zu verwenden, damit Sie Ihren Code später in der Cloud ausführen können, indem Sie den verwendeten Endpunkt ändern. 
+  Die lokale Version von DynamoDB gibt für `billingModeSummary.` immer null zurück 
+  Die lokale Version von DynamoDB `AWS_ACCESS_KEY_ID` kann nur Buchstaben (A–Z, a–z) und Zahlen (0–9) enthalten. 
+ DynamoDB local unterstützt keine [Point-in-time Wiederherstellung (PITR](Point-in-time-recovery.md)).

**Topics**
+ [Befehlszeilenoptionen](#DynamoDBLocal.CommandLineOptions)
+ [Festlegen des lokalen Endpunkts](#DynamoDBLocal.Endpoint)
+ [Unterschiede zwischen der herunterladbaren Version von DynamoDB und dem DynamoDB-Webservice](#DynamoDBLocal.Differences)

## Befehlszeilenoptionen
<a name="DynamoDBLocal.CommandLineOptions"></a>

 Mit der herunterladbaren Version von DynamoDB können Sie die folgenden Befehlszeilenoptionen verwenden: 
+  `-cors``value`— Aktiviert die Unterstützung für Cross-Origin Resource Sharing (CORS) für. JavaScript Sie müssen eine durch Komma getrennte Liste zum Zulassen spezifischer Domänen bereitstellen. Die Standardeinstellung für `-cors` ist ein Stern (\$1), der öffentlichen Zugriff zulässt. 
+  `-dbPath` `value` – Das Verzeichnis, in das DynamoDB seine Datenbankdatei schreibt. Wenn Sie diese Option nicht angeben, wird die Datei in das aktuelle Verzeichnis geschrieben. Sie können nicht `-dbPath` und `-inMemory` gleichzeitig angeben. 
+  `-delayTransientStatuses` – Veranlasst DynamoDB, Verzögerungen für bestimmte Operationen einzuführen. DynamoDB (herunterladbare Version) kann einige Aufgaben fast sofort ausführen, z. B. create/update/delete Operationen an Tabellen und Indizes. Der Service DynamoDB benötigt für diese Aufgaben jedoch mehr Zeit. Durch Festlegen dieses Parameters kann DynamoDB bei Ausführung auf einem Computer das Verhalten des DynamoDB-Webservices besser simulieren. (Gegenwärtig führt dieser Parameter Verzögerungen nur für globale sekundäre Indizes mit dem Status *CREATING* oder *DELETING* ein.) 
+  `-help` – Druckt eine Nutzungszusammenfassung sowie Optionen. 
+  `-inMemory` – DynamoDB wird im Speicher anstatt mit einer Datenbankdatei ausgeführt. Wenn Sie DynamoDB beenden, werden keine Daten gespeichert. Sie können nicht `-dbPath` und `-inMemory` gleichzeitig angeben. 
+  `-optimizeDbBeforeStartup` – Optimiert die zugrunde liegenden Datenbanktabellen vor dem Start von DynamoDB auf Ihrem Computer. Wenn Sie diesen Parameter verwenden, müssen Sie außerdem `-dbPath` angeben. 
+  `-port` `value` – Die Portnummer, die DynamoDB für die Kommunikation mit Ihrer Anwendung verwendet. Wenn Sie diese Option nicht angeben, lautet der Standardport `8000`. 
**Anmerkung**  
 DynamoDB verwendet standardmäßig Port 8000. Wenn Port 8000 nicht verfügbar ist, wird eine Ausnahme ausgelöst. Mit der Option `-port` können Sie eine andere Portnummer angeben. Um eine vollständige Liste der DynamoDB-Laufzeitoptionen, einschließlich `-port`, zu erhalten, geben Sie folgenden Befehl ein:   
 `java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help` 
+  `-sharedDb` – `-sharedDb` DynamoDB verwendet eine einzige Datenbankdatei anstatt separater Dateien für jede Anmeldeinformation und Region. 
+  `-disableTelemetry`: Wenn dies angegeben ist, sendet die lokale Version von DynamoDB keine Telemetrie. 
+ `-version` – Zeigt die Version der lokalen Version von DynamoDB.

## Festlegen des lokalen Endpunkts
<a name="DynamoDBLocal.Endpoint"></a>

 Standardmäßig verwenden die Tools AWS SDKs und Endpunkte für den Amazon DynamoDB DynamoDB-Webservice. Um die Tools SDKs und mit der herunterladbaren Version von DynamoDB zu verwenden, müssen Sie den lokalen Endpunkt angeben: 

 `http://localhost:8000` 

### AWS Command Line Interface
<a name="DynamoDBLocal.Endpoint.CLI"></a>

 Sie können die AWS Command Line Interface (AWS CLI) verwenden, um mit herunterladbarem DynamoDB zu interagieren. 

 Verwenden Sie den `--endpoint-url`-Parameter , um auf die lokal ausgeführte DynamoDB-Version zuzugreifen. Im Folgenden finden Sie ein Beispiel für die Verwendung von AWS CLI , um die Tabellen in DynamoDB auf Ihrem Computer aufzulisten. 

```
aws dynamodb list-tables --endpoint-url http://localhost:8000
```

**Anmerkung**  
 Die herunterladbare Version von DynamoDB AWS CLI kann nicht als Standardendpunkt verwendet werden. Daher müssen Sie `--endpoint-url` bei jedem AWS CLI Befehl angeben. 

### AWS SDKs
<a name="DynamoDBLocal.Endpoint.SDK"></a>

 Die Art und Weise, wie Sie einen Endpunkt angeben, hängt davon ab, welche Programmiersprache und welches AWS -SDK Sie verwenden. In den folgenden Abschnitten wird die entsprechende Vorgehensweise beschrieben: 
+  [Java: AWS Region und Endpunkt festlegen](CodeSamples.Java.md#CodeSamples.Java.RegionAndEndpoint)(DynamoDB local unterstützt das AWS SDK for Java V1 und V2) 
+ CodeSamples.Java. RegionAndEndpoint [.NET: AWS Region und Endpunkt festlegen](CodeSamples.DotNet.md#CodeSamples.DotNet.RegionAndEndpoint) 

## Unterschiede zwischen der herunterladbaren Version von DynamoDB und dem DynamoDB-Webservice
<a name="DynamoDBLocal.Differences"></a>

 Die herunterladbare Version von DynamoDB ist nur für Zwecke der Anwendungsentwicklung und Tests vorgesehen. Der DynamoDB-Webservice hingegen ist ein verwalteter Service mit Skalierbarkeits-, Verfügbarkeits- und Haltbarkeitsfunktionen, die ideal für den Einsatz in der Produktion geeignet sind. 

 Die herunterladbare Version von DynamoDB unterscheidet sich folgendermaßen vom Webservice: 
+ AWS-Regionen und distinct AWS-Konten werden auf Client-Ebene nicht unterstützt. 
+  Einstellungen für den bereitgestellten Durchsatz werden in der herunterladbaren Version von DynamoDB ignoriert, auch wenn die `CreateTable`-Operation diese benötigt. Für `CreateTable` können Sie beliebige Zahlen für den bereitgestellten Lese- und Schreibdurchsatz angeben, auch wenn diese Zahlen nicht verwendet werden. Sie können `UpdateTable` beliebig oft pro Tag aufrufen. Alle Änderungen an Werten des bereitgestellten Durchsatzes werden jedoch ignoriert. 
+  `Scan`-Operationen werden sequenziell durchgeführt. Parallele Scans werden nicht unterstützt. Die Parameter `Segment` und `TotalSegments` der `Scan`-Operation werden ignoriert. 
+  Die Geschwindigkeit der Lese- und Schreibvorgänge in den Tabellendaten ist nur durch die Geschwindigkeit des Computers begrenzt. Die Vorgänge `CreateTable`, `UpdateTable` und `DeleteTable` werden umgehend ausgeführt und der Tabellenstatus ist jederzeit ACTIVE. `UpdateTable`-Vorgänge, die nur die Einstellungen zum bereitgestellten Durchsatz für Tabellen oder globale sekundäre Indizes ändern, werden umgehend ausgeführt. Wenn eine `UpdateTable`-Operation globale sekundäre Indizes erstellt oder löscht, durchlaufen diese Indizes die normalen Status (wie CREATING bzw. DELETING), bevor sie in den Status ACTIVE übergehen. Die Tabelle bleibt während dieser Zeit im Status ACTIVE. 
+  Leseoperationen sind Eventually Consistent. Aufgrund der Geschwindigkeit, mit der die lokale Version von DynamoDB auf Ihrem Computer ausgeführt wird, sind die meisten Lesevorgänge allerdings tatsächlich vom Typ „Strongly Consistent”. 
+  Elementauflistungsmetriken und Elementauflistungsgrößen werden nicht nachverfolgt. In Operationsantworten werden anstelle der Elementauflistungsmetriken Nullen zurückgegeben. 
+  In DynamoDB gibt es für Daten, die pro Ergebnissatz zurückgegeben werden, ein Limit von 1 MB. Sowohl der DynamoDB-Webservice als auch die herunterladbare Version setzen dieses Limit durch. Beim Abfragen eines Indexes berechnet der DynamoDB-Service jedoch nur die Größe des projizierten Schlüssels und der Attribute. Im Gegensatz dazu berechnet die herunterladbare Version von DynamoDB die Größe des gesamten Elements. 
+  Bei der Verwendung von DynamoDB Streams kann die Rate, mit der Shards erstellt werden, abweichen. Im DynamoDB-Webservice wird die Shard-Erstellung teilweise von Aktivitäten der Tabellenpartition beeinflusst. Wenn Sie DynamoDB lokal ausführen, gibt es keine Tabellenpartitionierung. In beiden Fällen sind Shards flüchtig, sodass Ihre Anwendung nicht vom Shard-Verhalten abhängt. 
+  `TransactionConflictExceptions`werden nicht von herunterladbarem DynamoDB für Transaktionen ausgelöst. APIs Wir empfehlen die Verwendung eines Java-Mocking-Frameworks für die Simulation von `TransactionConflictExceptions` im DynamoDB-Handler, um zu prüfen, wie Ihre Anwendung auf miteinander in Konflikt stehende Transaktionen reagiert. 
+  Im DynamoDB-Webdienst wird zwischen Groß- und Kleinschreibung unterschieden, unabhängig davon, ob auf Tabellennamen über die AWS CLI Konsole oder über zugegriffen wird. Eine Tabelle mit dem Namen `Authors` und eine mit dem Namen `authors` können als separate Tabellen vorhanden sein. In der Downloadversion muss bei Tabellennamen die Groß-/Kleinschreibung beachtet werden. Ein Versuch, diese beiden Tabellen zu erstellen, würde einen Fehler verursachen. 
+ Tagging wird in der herunterladbaren Version von DynamoDB nicht unterstützt.
+ Die herunterladbare Version von DynamoDB ignoriert den [Limit-Parameter](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExecuteStatement.html#DDB-ExecuteStatement-request-Limit) in. [ExecuteStatement](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ExecuteStatement.html)

# Versionsverlauf für die lokale Version von DynamoDB
<a name="DynamoDBLocalHistory"></a>

In der folgenden Tabelle sind wichtige Änderungen in jeder Version von *der lokalen Version von DynamoDB* beschrieben.


****  

| Version | Änderungen | Beschreibung | Date | 
| --- | --- | --- | --- | 
| 3.3.0 |  Unterstützung für Schlüssel mit mehreren Attributen für globale Sekundärindizes hinzufügen  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  19. Januar 2026  | 
| 3.2.0 |  Kompatibilitätsprobleme mit mehreren Kotlin-Versionen wurden behoben  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  09. Januar 2026  | 
| 3.1.0 |  Verbesserung der Leistung von PartiQL-Abfragen, Einbeziehung der Joda-Zeitabhängigkeit  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  14. September 2025  | 
| 3.0.0 |  Migration von AWS SDK Java V1 zu V2  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  17. Juli 2025  | 
| 2.6.0 |  Support Tabellen-ARN als Tabellennamen in DynamoDB APIs Leistungsverbesserungen und Sicherheitsupdates  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  13. März 2025  | 
| 2.5.4 |  Aktualisierung von Jetty-Abhängigkeiten  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  12. Dezember 2024  | 
| 2.5.3 |  Aktualisierung von Jackson-Abhängigkeiten auf 2.17.x in Log4j Core (Behebung der Schwachstelle CVE-2022-1471)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  6. November 2024  | 
| 2.5.2 | Bugfix für den Workflow „Tabelle aktualisieren“ | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  | 20. Juni 2024 | 
| 2.5.1 | Patch für mit der OndemandThroughPut-Feature eingeführte Fehler  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html) | 5. Juni 2024 | 
| 2.5.0 |  Unterstützung des konfigurierbaren maximalen Durchsatzes für On-Demand-Tabellen, `ReturnValuesOnConditionCheckFailure`, `BatchExecuteStatement` und `ExecuteTransactionRequest`  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  28. Mai 2024  | 
| 2.4.0 |  Unterstützung von `ReturnValuesOnConditionCheckFailure` – Embedded-Modus  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  17. April 2024  | 
| 2.3.0 |  Aktualisierung von Jetty und JDK  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  14. März 2024  | 
| 2.2.0 |  Löschschutz für Tabellen und Parameter `ReturnValuesOnConditionCheckFailure` hinzugefügt  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  14. Dezember 2023  | 
| 2.1.0 |  Support für SQLLite native Bibliotheken für Maven-Projekte und Hinzufügen von Telemetrie  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  23. Oktober 2023  | 
| 2.0.0 |  Migration von Javax zu Jakarta Namespace und Support JDK11   |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  5. Juli 2023  | 
| 1.25.1 |  Aktualisierung von Jackson-Abhängigkeiten auf 2.17.x in Log4j Core (Behebung der Schwachstelle CVE-2022-1471)  |  Aktualisierung der Jackson-Abhängigkeiten auf 2.17.x in Log4j Core (Behebung der Schwachstelle CVE-2022-1471), um eine kritische Schwachstelle in der SnakeYAML-Bibliothek zu schließen, bei der es sich um eine transitive Abhängigkeit handelt  |  6. November 2024  | 
| 1.25.0 |  Löschschutz für Tabellen und Parameter `ReturnValuesOnConditionCheckFailure` hinzugefügt  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  18. Dezember 2023  | 
| 1.24.0 |  Support für SQLLite native Bibliotheken für Maven-Projekte und Hinzufügen von Telemetrie  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  23. Oktober 2023  | 
| 1.23.0 |  Umgang mit ungültigen Zugriffs- und Geheimschlüsseln beim Serverstart  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  28. Juni 2023  | 
| 1.22.0 |  Unterstützung von Limit-Operation für PartiQL  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  08. Juni 2023  | 
| 1.21.0 |  Unterstützung für 100 Aktionen pro Transaktion  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  26. Januar 2023  | 
| 1.20.0 |  Unterstützung für M1 Mac hinzugefügt  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  |  12. September 2022  | 
| 1.19.0 |  PartiQL-Parser aktualisiert  |  PartiQL-Parser und andere verwandte Bibliotheken aktualisiert  |  27. Juli 2022  | 
| 1.18.0 | log4j-Core und Jackson-Core aktualisiert | log4j-Core auf 2.17.1 und Jackson-Core 2.10.x auf 2.12.0 aktualisiert | 10. Januar 2022 | 
| 1.17.2 | log4j-Core aktualisiert | log4j-Core-Abhängigkeit auf Version 2.16 aktualisiert | 16. Januar 2021 | 
| 1.17.1 | log4j-Core aktualisiert | log4j-core-Abhängigkeit aktualisiert, um den Zero-Day-Exploit zu patchen und die Ausführung von Code aus der Ferne zu verhindern – Log4Shel | 10. Januar 2021 | 
| 1.17.0 | Veraltete Javascript-Web-Shell |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/DynamoDBLocalHistory.html)  | 08. Januar 2021 | 

# Telemetrie in der lokalen Version von DynamoDB
<a name="DynamoDBLocalTelemetry"></a>

 Bei AWS entwickeln und lancieren wir Dienstleistungen auf der Grundlage dessen, was wir aus Interaktionen mit Kunden lernen, und wir nutzen Kundenfeedback, um unsere Produkte zu verbessern. Bei Telemetrie handelt es sich um zusätzliche Informationen, die uns dabei helfen, die Anforderungen unserer Kunden besser zu verstehen, Probleme zu diagnostizieren und Features bereitzustellen, mit denen das Erlebnis unserer Kunden verbessert wird. 

 Die lokale Version von DynamoDB erfasst Telemetriedaten, z. B. allgemeine Nutzungsmetriken, System- und Umgebungsinformationen sowie Fehler. Einzelheiten zu der Art der erfassten Telemetrie finden Sie unter [Arten von erfassten Informationen](#DynamoDBLocalTelemetry.TypesOfInformationCollected). 

 Die lokale Version von DynamoDB erfasst keine personenbezogenen Daten wie Benutzernamen oder E-Mail-Adressen. Außerdem werden keine sensiblen Informationen auf Projektebene extrahiert. 

 Als Kunde haben Sie die Kontrolle darüber, ob die Telemetrie aktiviert ist, und Sie können Ihre Einstellungen jederzeit ändern. Wenn die Telemetrie aktiviert bleibt, sendet die lokale Version von DynamoDB Telemetriedaten im Hintergrund, ohne dass eine zusätzliche Kundeninteraktion erforderlich ist. 

## Telemetrie mithilfe von Befehlszeilenoptionen ausschalten
<a name="DynamoDBLocalTelemetry.cli"></a>

 Sie können Telemetrie beim Start der lokalen Version von DynamoDB mit der Option `-disableTelemetry` mithilfe von Befehlszeilenoptionen deaktivieren. Weitere Informationen finden Sie unter [Befehlszeilenoptionen](DynamoDBLocal.UsageNotes.md#DynamoDBLocal.CommandLineOptions).

## Telemetrie für eine einzelne Sitzung ausschalten
<a name="DynamoDBLocalTelemetry.TurnOffTelemetrySingleSession"></a>

 In macOS- und Linux-Betriebssystemen können Sie die Telemetrie für eine einzelne Sitzung ausschalten. Um die Telemetrie für Ihre aktuelle Sitzung zu deaktivieren, führen Sie den folgenden Befehl aus, um die Umgebungsvariable `DDB_LOCAL_TELEMETRY` auf `false` festzulegen. Wiederholen Sie den Befehl für jedes neue Terminal oder jede neue Sitzung. 

```
export DDB_LOCAL_TELEMETRY=0
```

## Telemetrie für Ihr Profil in allen Sitzungen ausschalten
<a name="DynamoDBLocalTelemetry.TurnOffTelemetryForAllSessions"></a>

 Führen Sie die folgenden Befehle aus, um die Telemetrie für alle Sitzungen zu deaktivieren, wenn Sie die lokale Version von DynamoDB auf Ihrem Betriebssystem ausführen. 

**Aktivieren von Telemetrie unter Linux**

1.  Führen Sie Folgendes aus: 

   ```
   echo "export DDB_LOCAL_TELEMETRY=0" >>~/.profile
   ```

1.  Führen Sie Folgendes aus: 

   ```
   source ~/.profile
   ```

**Aktivieren von Telemetrie unter macOS**

1.  Führen Sie Folgendes aus: 

   ```
   echo "export DDB_LOCAL_TELEMETRY=0" >>~/.profile
   ```

1.  Führen Sie Folgendes aus: 

   ```
   source ~/.profile
   ```

**Aktivieren von Telemetrie unter Windows**

1.  Führen Sie Folgendes aus: 

   ```
   setx DDB_LOCAL_TELEMETRY 0
   ```

1.  Führen Sie Folgendes aus: 

   ```
   refreshenv
   ```

## Deaktivieren der Telemetrie mithilfe der lokalen eingebetteten Version von DynamoDB in Maven-Projekten
<a name="DynamoDBLocalTelemetry.maven"></a>

 Sie können die Telemetrie mithilfe der lokalen eingebetteten Version von DynamoDB in Maven-Projekten deaktivieren. 

```
boolean disableTelemetry = true;
// AWS SDK v1
 AmazonDynamoDB amazonDynamoDB = DynamoDBEmbedded.create(disableTelemetry).amazonDynamoDB();

// AWS SDK v2
DynamoDbClient ddbClientSDKv2Local = DynamoDBEmbedded.create(disableTelemetry).dynamoDbClient();
```

## Arten von erfassten Informationen
<a name="DynamoDBLocalTelemetry.TypesOfInformationCollected"></a>
+  **Nutzungsinformationen** — Die generische Telemetrie wie Server start/stop und die API oder Operation werden aufgerufen. 
+  **System- und Umgebungsinformationen**: Die Java-Version, das Betriebssystem (Windows, Linux oder macOS), die Umgebung, in der die lokale Version von DynamoDB ausgeführt wird (z. B. eigenständiges JAR, Docker-Container oder als Maven-Abhängigkeit), und Hashwerte von Nutzungsattributen. 

## Weitere Informationen
<a name="DynamoDBLocalTelemetry.LearnMore"></a>

 Die Telemetriedaten, die DynamoDB local sammelt, entsprechen den AWS Datenschutzrichtlinien. Weitere Informationen finden Sie hier: 
+  [AWS Nutzungsbedingungen](https://aws.amazon.com/service-terms/) 
+  [Häufig gestellte Fragen zum Datenschutz](https://aws.amazon.com/compliance/data-privacy-faq/) 

# Schritt 1: Erstellen einer Tabelle in DynamoDB
<a name="getting-started-step-1"></a>

In diesem Schritt erstellen Sie eine `Music`-Tabelle im Amazon DynamoDB. In dieser Tabelle befinden sich die folgenden Details:
+ Partitionsschlüssel: `Artist`
+ Sortierschlüssel: `SongTitle`

Weitere Informationen über Tabellen-Operationen finden Sie unter [Arbeiten mit Tabellen und Daten in DynamoDB](WorkingWithTables.md). 

**Anmerkung**  
Bevor Sie beginnen, sollten Sie sicherstellen, dass Sie die in [Voraussetzungen](GettingStartedDynamoDB.md#GettingStarted.SettingUp.DynamoWebService) beschriebenen Schritte befolgt haben.

## AWS-Managementkonsole
<a name="getting-started-step-1-Console"></a>

So erstellen Sie eine neue `Music`-Tabelle mithilfe der DynamoDB-Konsole:

1. Melden Sie sich bei der an AWS-Managementkonsole und öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus. 

1. Wählen Sie **Create table** (Tabelle erstellen) aus.

1. Geben Sie die **Tabellendetails** wie folgt ein:

   1. Geben Sie unter **Tabellenname** **Music** ein.

   1. Geben Sie unter **Partitionsschlüssel** den Wert **Artist** ein.

   1. Geben Sie unter **Sortierschlüssel** den Wert **SongTitle** ein.

1. Behalten Sie unter **Tabelleneinstellungen** die Standardauswahl **Standardeinstellungen** bei.

1. Klicken Sie auf **Tabelle erstellen**, um die Tabelle zu erstellen.  
![\[Die Seite „Tabelle erstellen“ mit ausgefüllten Tabellendetails.\]](http://docs.aws.amazon.com/de_de/amazondynamodb/latest/developerguide/images/GettingStarted/CreateTableMusic.png)

1. Sobald die Tabelle den Status `ACTIVE` aufweist, empfehlen wir, für die Tabelle die Option [Zeitpunktbezogene Backups für DynamoDB](Point-in-time-recovery.md) zu aktivieren, indem Sie die folgenden Schritte ausführen:

   1. Klicken Sie auf den Tabellennamen, um die Tabelle zu öffnen.

   1. Wählen Sie **Backups** aus.

   1. Wählen Sie im **Bereich **Point-in-time Wiederherstellung (PITR**) die Option Bearbeiten** aus.

   1. Wählen Sie auf der Seite **„ point-in-timeWiederherstellungseinstellungen bearbeiten**“ die Option ** point-in-timeWiederherstellung aktivieren** aus.

   1. Wählen Sie **Änderungen speichern ** aus.

## AWS CLI
<a name="getting-started-step-1-CLI"></a>

Im folgenden AWS CLI Beispiel wird eine neue `Music` Tabelle mit erstellt`create-table`.

**Linux**

```
aws dynamodb create-table \
    --table-name Music \
    --attribute-definitions \
        AttributeName=Artist,AttributeType=S \
        AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --billing-mode PAY_PER_REQUEST \
    --table-class STANDARD
```

**Windows CMD**

```
aws dynamodb create-table ^
    --table-name Music ^
    --attribute-definitions ^
        AttributeName=Artist,AttributeType=S ^
        AttributeName=SongTitle,AttributeType=S ^
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE ^
    --billing-mode PAY_PER_REQUEST ^
    --table-class STANDARD
```

Bei Verwenden von `create-table` wird das folgende Beispielergebnis zurückgegeben.

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Artist",
                "AttributeType": "S"
            },
            {
                "AttributeName": "SongTitle",
                "AttributeType": "S"
            }
        ],
        "TableName": "Music",
        "KeySchema": [
            {
                "AttributeName": "Artist",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "SongTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2023-03-29T12:11:43.379000-04:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-east-1:111122223333:table/Music",
        "TableId": "60abf404-1839-4917-a89b-a8b0ab2a1b87",
        "TableClassSummary": {
            "TableClass": "STANDARD"
        }
    }
}
}
```

Beachten Sie, dass für das Feld `TableStatus` der Wert `CREATING` festgelegt ist.

Um zu überprüfen, dass DynamoDB die Erstellung der `Music`-Tabelle abgeschlossen hat, verwenden Sie den Befehl `describe-table`. 

**Linux**

```
 aws dynamodb describe-table --table-name Music | grep TableStatus
```

**Windows CMD**

```
 aws dynamodb describe-table --table-name Music | findstr TableStatus
```

Dieser Befehl gibt das folgende Ergebnis zurück. Wenn DynamoDB die Erstellung der Tabelle abgeschlossen hat, wird der Wert `TableStatus` des Felds auf `ACTIVE` festgelegt. 

```
"TableStatus": "ACTIVE",
```

Sobald die Tabelle den Status `ACTIVE` aufweist, sollten Sie [Zeitpunktbezogene Backups für DynamoDB](Point-in-time-recovery.md) für die Tabelle aktivieren, indem Sie den folgenden Befehl ausführen:

**Linux**

```
aws dynamodb update-continuous-backups \ 
    --table-name Music \ 
    --point-in-time-recovery-specification \ 
        PointInTimeRecoveryEnabled=true
```

**Windows CMD**

```
aws dynamodb update-continuous-backups --table-name Music --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
```

Dieser Befehl gibt das folgende Ergebnis zurück.

```
{
    "ContinuousBackupsDescription": {
        "ContinuousBackupsStatus": "ENABLED",
        "PointInTimeRecoveryDescription": {
            "PointInTimeRecoveryStatus": "ENABLED",
            "EarliestRestorableDateTime": "2023-03-29T12:18:19-04:00",
            "LatestRestorableDateTime": "2023-03-29T12:18:19-04:00"
        }
    }
}
```

**Anmerkung**  
Die Aktivierung kontinuierlicher Backups mit point-in-time Wiederherstellung hat Auswirkungen auf die Kosten. Weitere Informationen zu Preisen finden Sie unter [Amazon DynamoDB – Preise](https://aws.amazon.com/dynamodb/pricing).

## AWS SDK
<a name="getting-started-step-1-SDK"></a>

In den folgenden Codebeispielen wird gezeigt, wie eine DynamoDB-Tabelle mit einem AWS -SDK erstellt wird.

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Creates a new Amazon DynamoDB table and then waits for the new
    /// table to become active.
    /// </summary>
    /// <param name="tableName">The name of the table to create.</param>
    /// <returns>A Boolean value indicating the success of the operation.</returns>
    public async Task<bool> CreateMovieTableAsync(string tableName)
    {
        try
        {
            var response = await _amazonDynamoDB.CreateTableAsync(new CreateTableRequest
            {
                TableName = tableName,
                AttributeDefinitions = new List<AttributeDefinition>()
                {
                    new AttributeDefinition
                    {
                        AttributeName = "title",
                        AttributeType = ScalarAttributeType.S,
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "year",
                        AttributeType = ScalarAttributeType.N,
                    },
                },
                KeySchema = new List<KeySchemaElement>()
                {
                    new KeySchemaElement
                    {
                        AttributeName = "year",
                        KeyType = KeyType.HASH,
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "title",
                        KeyType = KeyType.RANGE,
                    },
                },
                BillingMode = BillingMode.PAY_PER_REQUEST,
            });

            // Wait until the table is ACTIVE and then report success.
            Console.Write("Waiting for table to become active...");

            var request = new DescribeTableRequest
            {
                TableName = response.TableDescription.TableName,
            };

            TableStatus status;

            int sleepDuration = 2000;

            do
            {
                Thread.Sleep(sleepDuration);

                var describeTableResponse = await _amazonDynamoDB.DescribeTableAsync(request);
                status = describeTableResponse.Table.TableStatus;

                Console.Write(".");
            }
            while (status != "ACTIVE");

            return status == TableStatus.ACTIVE;
        }
        catch (ResourceInUseException ex)
        {
            Console.WriteLine($"Table {tableName} already exists. {ex.Message}");
            throw;
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while creating table {tableName}. {ex.Message}");
            throw;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while creating table {tableName}. {ex.Message}");
            throw;
        }
    }
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/CreateTable)in der *AWS SDK für .NET API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
###############################################################################
# function dynamodb_create_table
#
# This function creates an Amazon DynamoDB table.
#
# Parameters:
#       -n table_name  -- The name of the table to create.
#       -a attribute_definitions -- JSON file path of a list of attributes and their types.
#       -k key_schema -- JSON file path of a list of attributes and their key types.
#
#  Returns:
#       0 - If successful.
#       1 - If it fails.
###############################################################################
function dynamodb_create_table() {
  local table_name attribute_definitions key_schema response
  local option OPTARG # Required to use getopts command in a function.

  #######################################
  # Function usage explanation
  #######################################
  function usage() {
    echo "function dynamodb_create_table"
    echo "Creates an Amazon DynamoDB table with on-demand billing."
    echo " -n table_name  -- The name of the table to create."
    echo " -a attribute_definitions -- JSON file path of a list of attributes and their types."
    echo " -k key_schema -- JSON file path of a list of attributes and their key types."
    echo ""
  }

  # Retrieve the calling parameters.
  while getopts "n:a:k:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      a) attribute_definitions="${OPTARG}" ;;
      k) key_schema="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  if [[ -z "$attribute_definitions" ]]; then
    errecho "ERROR: You must provide an attribute definitions json file path the -a parameter."
    usage
    return 1
  fi

  if [[ -z "$key_schema" ]]; then
    errecho "ERROR: You must provide a key schema json file path the -k parameter."
    usage
    return 1
  fi

  iecho "Parameters:\n"
  iecho "    table_name:   $table_name"
  iecho "    attribute_definitions:   $attribute_definitions"
  iecho "    key_schema:   $key_schema"
  iecho ""

  response=$(aws dynamodb create-table \
    --table-name "$table_name" \
    --attribute-definitions file://"$attribute_definitions" \
    --billing-mode PAY_PER_REQUEST \
    --key-schema file://"$key_schema" )

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports create-table operation failed.$response"
    return 1
  fi

  return 0
}
```
Die in diesem Beispiel verwendeten Hilfsfunktionen.  

```
###############################################################################
# function iecho
#
# This function enables the script to display the specified text only if
# the global variable $VERBOSE is set to true.
###############################################################################
function iecho() {
  if [[ $VERBOSE == true ]]; then
    echo "$@"
  fi
}

###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/CreateTable)in der *AWS CLI Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Create an Amazon DynamoDB table.
/*!
  \sa createTable()
  \param tableName: Name for the DynamoDB table.
  \param primaryKey: Primary key for the DynamoDB table.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
 */
bool AwsDoc::DynamoDB::createTable(const Aws::String &tableName,
                                   const Aws::String &primaryKey,
                                   const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);

    std::cout << "Creating table " << tableName <<
              " with a simple primary key: \"" << primaryKey << "\"." << std::endl;

    Aws::DynamoDB::Model::CreateTableRequest request;

    Aws::DynamoDB::Model::AttributeDefinition hashKey;
    hashKey.SetAttributeName(primaryKey);
    hashKey.SetAttributeType(Aws::DynamoDB::Model::ScalarAttributeType::S);
    request.AddAttributeDefinitions(hashKey);

    Aws::DynamoDB::Model::KeySchemaElement keySchemaElement;
    keySchemaElement.WithAttributeName(primaryKey).WithKeyType(
            Aws::DynamoDB::Model::KeyType::HASH);
    request.AddKeySchema(keySchemaElement);

    Aws::DynamoDB::Model::ProvisionedThroughput throughput;
    throughput.WithReadCapacityUnits(5).WithWriteCapacityUnits(5);
    request.SetProvisionedThroughput(throughput);
    request.SetTableName(tableName);

    const Aws::DynamoDB::Model::CreateTableOutcome &outcome = dynamoClient.CreateTable(
            request);
    if (outcome.IsSuccess()) {
        std::cout << "Table \""
                  << outcome.GetResult().GetTableDescription().GetTableName() <<
                  " created!" << std::endl;
    }
    else {
        std::cerr << "Failed to create table: " << outcome.GetError().GetMessage()
                  << std::endl;
        return false;
    }

    return waitTableActive(tableName, dynamoClient);
}
```
Code, der darauf wartet, dass die Tabelle aktiv wird.  

```
//! Query a newly created DynamoDB table until it is active.
/*!
  \sa waitTableActive()
  \param waitTableActive: The DynamoDB table's name.
  \param dynamoClient: A DynamoDB client.
  \return bool: Function succeeded.
*/
bool AwsDoc::DynamoDB::waitTableActive(const Aws::String &tableName,
                                       const Aws::DynamoDB::DynamoDBClient &dynamoClient) {

    // Repeatedly call DescribeTable until table is ACTIVE.
    const int MAX_QUERIES = 20;
    Aws::DynamoDB::Model::DescribeTableRequest request;
    request.SetTableName(tableName);

    int count = 0;
    while (count < MAX_QUERIES) {
        const Aws::DynamoDB::Model::DescribeTableOutcome &result = dynamoClient.DescribeTable(
                request);
        if (result.IsSuccess()) {
            Aws::DynamoDB::Model::TableStatus status = result.GetResult().GetTable().GetTableStatus();

            if (Aws::DynamoDB::Model::TableStatus::ACTIVE != status) {
                std::this_thread::sleep_for(std::chrono::seconds(1));
            }
            else {
                return true;
            }
        }
        else {
            std::cerr << "Error DynamoDB::waitTableActive "
                      << result.GetError().GetMessage() << std::endl;
            return false;
        }
        count++;
    }
    return false;
}
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/CreateTable)in der *AWS SDK für C\$1\$1 API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**Beispiel 1: So erstellen Sie eine Tabelle mit Tags**  
Im folgenden Beispiel für `create-table` werden die angegebenen Attribute und das angegebene Schlüsselschema verwendet, um eine Tabelle mit dem Namen `MusicCollection` zu erstellen. Diese Tabelle verwendet den bereitgestellten Durchsatz und wird im Ruhezustand mit dem standardmäßigen AWS eigenen CMK verschlüsselt. Der Befehl weist der Tabelle außerdem ein Tag mit dem Schlüssel `Owner` und dem Wert `blueTeam` zu.  

```
aws dynamodb create-table \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
    --tags Key=Owner,Value=blueTeam
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Artist",
                "AttributeType": "S"
            },
            {
                "AttributeName": "SongTitle",
                "AttributeType": "S"
            }
        ],
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "WriteCapacityUnits": 5,
            "ReadCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "TableName": "MusicCollection",
        "TableStatus": "CREATING",
        "KeySchema": [
            {
                "KeyType": "HASH",
                "AttributeName": "Artist"
            },
            {
                "KeyType": "RANGE",
                "AttributeName": "SongTitle"
            }
        ],
        "ItemCount": 0,
        "CreationDateTime": "2020-05-26T16:04:41.627000-07:00",
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 2: So erstellen Sie eine Tabelle im On-Demand-Modus**  
Im folgenden Beispiel wird mit dem On-Demand-Modus anstelle des bereitgestellten Durchsatzmodus eine Tabelle mit dem Namen `MusicCollection` erstellt. Dies ist nützlich für Tabellen mit unvorhersehbaren Workloads.  

```
aws dynamodb create-table \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --billing-mode PAY_PER_REQUEST
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Artist",
                "AttributeType": "S"
            },
            {
                "AttributeName": "SongTitle",
                "AttributeType": "S"
            }
        ],
        "TableName": "MusicCollection",
        "KeySchema": [
            {
                "AttributeName": "Artist",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "SongTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-05-27T11:44:10.807000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 0,
            "WriteCapacityUnits": 0
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "BillingModeSummary": {
            "BillingMode": "PAY_PER_REQUEST"
        }
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 3: So erstellen Sie eine Tabelle und verschlüsseln sie mit einem kundenseitig verwalteten Schlüssel (Customer Managed Key; CMK).**  
Im folgenden Beispiel wird eine Tabelle mit dem Namen `MusicCollection` erstellt und mithilfe eines kundenseitig verwalteten Schlüssels (Customer Managed Key; CMK) verschlüsselt.  

```
aws dynamodb create-table \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
    --sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=abcd1234-abcd-1234-a123-ab1234a1b234
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Artist",
                "AttributeType": "S"
            },
            {
                "AttributeName": "SongTitle",
                "AttributeType": "S"
            }
        ],
        "TableName": "MusicCollection",
        "KeySchema": [
            {
                "AttributeName": "Artist",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "SongTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-05-27T11:12:16.431000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "SSEDescription": {
            "Status": "ENABLED",
            "SSEType": "KMS",
            "KMSMasterKeyArn": "arn:aws:kms:us-west-2:123456789012:key/abcd1234-abcd-1234-a123-ab1234a1b234"
        }
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Bespiel 4: So erstellen Sie eine Tabelle mit einem lokalen sekundären Index**  
Im folgenden Beispiel werden die angegebenen Attribute und das angegebene Schlüsselschema verwendet, um eine Tabelle namens `MusicCollection` mit dem lokalen sekundären Index `AlbumTitleIndex` zu erstellen.  

```
aws dynamodb create-table \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S AttributeName=AlbumTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --local-secondary-indexes \
        "[
            {
                \"IndexName\": \"AlbumTitleIndex\",
                \"KeySchema\": [
                    {\"AttributeName\": \"Artist\",\"KeyType\":\"HASH\"},
                    {\"AttributeName\": \"AlbumTitle\",\"KeyType\":\"RANGE\"}
                ],
                \"Projection\": {
                    \"ProjectionType\": \"INCLUDE\",
                    \"NonKeyAttributes\": [\"Genre\", \"Year\"]
                }
            }
        ]"
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "AlbumTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "Artist",
                "AttributeType": "S"
            },
            {
                "AttributeName": "SongTitle",
                "AttributeType": "S"
            }
        ],
        "TableName": "MusicCollection",
        "KeySchema": [
            {
                "AttributeName": "Artist",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "SongTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-05-26T15:59:49.473000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "LocalSecondaryIndexes": [
            {
                "IndexName": "AlbumTitleIndex",
                "KeySchema": [
                    {
                        "AttributeName": "Artist",
                        "KeyType": "HASH"
                    },
                    {
                        "AttributeName": "AlbumTitle",
                        "KeyType": "RANGE"
                    }
                ],
                "Projection": {
                    "ProjectionType": "INCLUDE",
                    "NonKeyAttributes": [
                        "Genre",
                        "Year"
                    ]
                },
                "IndexSizeBytes": 0,
                "ItemCount": 0,
                "IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection/index/AlbumTitleIndex"
            }
        ]
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 5: So erstellen Sie eine Tabelle mit einem globalen sekundären Index**  
Im folgenden Beispiel wird eine Tabelle mit dem Namen `GameScores` mit einem globalen sekundären Index namens `GameTitleIndex` erstellt. Die Basistabelle hat einen Partitionsschlüssel von `UserId` und einen Sortierschlüssel von `GameTitle`, mit dem Sie effizient die beste Punktzahl eines einzelnen Benutzers für ein bestimmtes Spiel finden können, während die GSI einen Partitionsschlüssel von `GameTitle` und einen Sortierschlüssel von `TopScore` hat, mit dem Sie finden Sie schnell die höchste Gesamtpunktzahl für ein bestimmtes Spiel.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S AttributeName=TopScore,AttributeType=N \
    --key-schema AttributeName=UserId,KeyType=HASH \
                AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --global-secondary-indexes \
        "[
            {
                \"IndexName\": \"GameTitleIndex\",
                \"KeySchema\": [
                    {\"AttributeName\":\"GameTitle\",\"KeyType\":\"HASH\"},
                    {\"AttributeName\":\"TopScore\",\"KeyType\":\"RANGE\"}
                ],
                \"Projection\": {
                    \"ProjectionType\":\"INCLUDE\",
                    \"NonKeyAttributes\":[\"UserId\"]
                },
                \"ProvisionedThroughput\": {
                    \"ReadCapacityUnits\": 10,
                    \"WriteCapacityUnits\": 5
                }
            }
        ]"
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "TopScore",
                "AttributeType": "N"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-05-26T17:28:15.602000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "GlobalSecondaryIndexes": [
            {
                "IndexName": "GameTitleIndex",
                "KeySchema": [
                    {
                        "AttributeName": "GameTitle",
                        "KeyType": "HASH"
                    },
                    {
                        "AttributeName": "TopScore",
                        "KeyType": "RANGE"
                    }
                ],
                "Projection": {
                    "ProjectionType": "INCLUDE",
                    "NonKeyAttributes": [
                        "UserId"
                    ]
                },
                "IndexStatus": "CREATING",
                "ProvisionedThroughput": {
                    "NumberOfDecreasesToday": 0,
                    "ReadCapacityUnits": 10,
                    "WriteCapacityUnits": 5
                },
                "IndexSizeBytes": 0,
                "ItemCount": 0,
                "IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameTitleIndex"
            }
        ]
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 6: So erstellen Sie eine Tabelle mit mehreren globalen sekundären Indizes gleichzeitig**  
Im folgenden Beispiel wird eine Tabelle namens `GameScores` mit zwei globalen sekundären Indizes erstellt. Die GSI-Schemas werden über eine Datei und nicht über die Befehlszeile übergeben.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S AttributeName=TopScore,AttributeType=N AttributeName=Date,AttributeType=S \
    --key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --global-secondary-indexes file://gsi.json
```
Inhalt von `gsi.json`:  

```
[
    {
        "IndexName": "GameTitleIndex",
        "KeySchema": [
            {
                "AttributeName": "GameTitle",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "TopScore",
                "KeyType": "RANGE"
            }
        ],
        "Projection": {
            "ProjectionType": "ALL"
        },
        "ProvisionedThroughput": {
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        }
    },
    {
        "IndexName": "GameDateIndex",
        "KeySchema": [
            {
                "AttributeName": "GameTitle",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "Date",
                "KeyType": "RANGE"
            }
        ],
        "Projection": {
            "ProjectionType": "ALL"
        },
        "ProvisionedThroughput": {
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        }
    }
]
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "Date",
                "AttributeType": "S"
            },
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "TopScore",
                "AttributeType": "N"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-08-04T16:40:55.524000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "GlobalSecondaryIndexes": [
            {
                "IndexName": "GameTitleIndex",
                "KeySchema": [
                    {
                        "AttributeName": "GameTitle",
                        "KeyType": "HASH"
                    },
                    {
                        "AttributeName": "TopScore",
                        "KeyType": "RANGE"
                    }
                ],
                "Projection": {
                    "ProjectionType": "ALL"
                },
                "IndexStatus": "CREATING",
                "ProvisionedThroughput": {
                    "NumberOfDecreasesToday": 0,
                    "ReadCapacityUnits": 10,
                    "WriteCapacityUnits": 5
                },
                "IndexSizeBytes": 0,
                "ItemCount": 0,
                "IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameTitleIndex"
            },
            {
                "IndexName": "GameDateIndex",
                "KeySchema": [
                    {
                        "AttributeName": "GameTitle",
                        "KeyType": "HASH"
                    },
                    {
                        "AttributeName": "Date",
                        "KeyType": "RANGE"
                    }
                ],
                "Projection": {
                    "ProjectionType": "ALL"
                },
                "IndexStatus": "CREATING",
                "ProvisionedThroughput": {
                    "NumberOfDecreasesToday": 0,
                    "ReadCapacityUnits": 5,
                    "WriteCapacityUnits": 5
                },
                "IndexSizeBytes": 0,
                "ItemCount": 0,
                "IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameDateIndex"
            }
        ]
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 7: So erstellen Sie eine Tabelle mit aktivierten Streams**  
Im folgenden Beispiel wird die Tabelle `GameScores` mit aktiviertem DynamoDB Streams aufgerufen. Sowohl neue als auch alte Images von jedem Element werden in den Stream geschrieben.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S \
    --key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --stream-specification StreamEnabled=TRUE,StreamViewType=NEW_AND_OLD_IMAGES
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2020-05-27T10:49:34.056000-07:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "StreamSpecification": {
            "StreamEnabled": true,
            "StreamViewType": "NEW_AND_OLD_IMAGES"
        },
        "LatestStreamLabel": "2020-05-27T17:49:34.056",
        "LatestStreamArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/stream/2020-05-27T17:49:34.056"
    }
}
```
Weitere Informationen finden Sie unter [Grundlegende Operationen für Tabellen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 8: So erstellen Sie eine Tabelle mit aktiviertem Keys-Only-Stream**  
Im folgenden Beispiel wird die Tabelle `GameScores` mit aktiviertem DynamoDB Streams aufgerufen. Nur die Schlüsselattribute von geänderten Elementen werden in den Stream geschrieben.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S \
    --key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --stream-specification StreamEnabled=TRUE,StreamViewType=KEYS_ONLY
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2023-05-25T18:45:34.140000+00:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "StreamSpecification": {
            "StreamEnabled": true,
            "StreamViewType": "KEYS_ONLY"
        },
        "LatestStreamLabel": "2023-05-25T18:45:34.140",
        "LatestStreamArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/stream/2023-05-25T18:45:34.140",
        "DeletionProtectionEnabled": false
    }
}
```
Weitere Informationen finden Sie unter [Ändern der Datenerfassung für DynamoDB Streams](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 9: So erstellen Sie eine Tabelle mit der Klasse Standard Infrequent Access**  
Im folgenden Beispiel wird eine Tabelle mit dem Namen `GameScores` erstellt und die Tabellenklasse Standard-Infrequent Access (DynamoDB Standard-IA) zugewiesen. Diese Tabellenklasse ist dafür optimiert, dass Speicher der Hauptkostenfaktor ist.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S \
    --key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --table-class STANDARD_INFREQUENT_ACCESS
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2023-05-25T18:33:07.581000+00:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "TableClassSummary": {
            "TableClass": "STANDARD_INFREQUENT_ACCESS"
        },
        "DeletionProtectionEnabled": false
    }
}
```
Weitere Informationen finden Sie unter [Tabellenklassen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.TableClasses.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 10: So erstellen Sie eine Tabelle mit aktiviertem Löschschutz**  
Im folgenden Beispiel wird eine Tabelle mit dem Namen `GameScores` erstellt und der Löschschutz aktiviert.  

```
aws dynamodb create-table \
    --table-name GameScores \
    --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S \
    --key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
    --deletion-protection-enabled
```
Ausgabe:  

```
{
    "TableDescription": {
        "AttributeDefinitions": [
            {
                "AttributeName": "GameTitle",
                "AttributeType": "S"
            },
            {
                "AttributeName": "UserId",
                "AttributeType": "S"
            }
        ],
        "TableName": "GameScores",
        "KeySchema": [
            {
                "AttributeName": "UserId",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "GameTitle",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "CREATING",
        "CreationDateTime": "2023-05-25T23:02:17.093000+00:00",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 10,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
        "TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "DeletionProtectionEnabled": true
    }
}
```
Weitere Informationen finden Sie unter [Verwenden des Löschschutzes](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html#WorkingWithTables.Basics.DeletionProtection) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Einzelheiten zur API finden Sie unter [CreateTable AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/create-table.html)*Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// CreateMovieTable creates a DynamoDB table with a composite primary key defined as
// a string sort key named `title`, and a numeric partition key named `year`.
// This function uses NewTableExistsWaiter to wait for the table to be created by
// DynamoDB before it returns.
func (basics TableBasics) CreateMovieTable(ctx context.Context) (*types.TableDescription, error) {
	var tableDesc *types.TableDescription
	table, err := basics.DynamoDbClient.CreateTable(ctx, &dynamodb.CreateTableInput{
		AttributeDefinitions: []types.AttributeDefinition{{
			AttributeName: aws.String("year"),
			AttributeType: types.ScalarAttributeTypeN,
		}, {
			AttributeName: aws.String("title"),
			AttributeType: types.ScalarAttributeTypeS,
		}},
		KeySchema: []types.KeySchemaElement{{
			AttributeName: aws.String("year"),
			KeyType:       types.KeyTypeHash,
		}, {
			AttributeName: aws.String("title"),
			KeyType:       types.KeyTypeRange,
		}},
		TableName:   aws.String(basics.TableName),
		BillingMode: types.BillingModePayPerRequest,
	})
	if err != nil {
		log.Printf("Couldn't create table %v. Here's why: %v\n", basics.TableName, err)
	} else {
		waiter := dynamodb.NewTableExistsWaiter(basics.DynamoDbClient)
		err = waiter.Wait(ctx, &dynamodb.DescribeTableInput{
			TableName: aws.String(basics.TableName)}, 5*time.Minute)
		if err != nil {
			log.Printf("Wait for table exists failed. Here's why: %v\n", err)
		}
		tableDesc = table.TableDescription
		log.Printf("Ccreating table test")
	}
	return tableDesc, err
}
```
+  Einzelheiten zur API finden Sie [CreateTable](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.CreateTable)in der *AWS SDK für Go API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import software.amazon.awssdk.core.waiters.WaiterResponse;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
import software.amazon.awssdk.services.dynamodb.model.CreateTableResponse;
import software.amazon.awssdk.services.dynamodb.model.DescribeTableRequest;
import software.amazon.awssdk.services.dynamodb.model.DescribeTableResponse;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement;
import software.amazon.awssdk.services.dynamodb.model.KeyType;
import software.amazon.awssdk.services.dynamodb.model.OnDemandThroughput;
import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput;
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
import software.amazon.awssdk.services.dynamodb.waiters.DynamoDbWaiter;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 * <p>
 * For more information, see the following documentation topic:
 * <p>
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 */
public class CreateTable {
    public static void main(String[] args) {
        final String usage = """

            Usage:
                <tableName> <key>

            Where:
                tableName - The Amazon DynamoDB table to create (for example, Music3).
                key - The key for the Amazon DynamoDB table (for example, Artist).
            """;

        if (args.length != 2) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        String key = args[1];
        System.out.println("Creating an Amazon DynamoDB table " + tableName + " with a simple primary key: " + key);
        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
            .region(region)
            .build();

        String result = createTable(ddb, tableName, key);
        System.out.println("New table is " + result);
        ddb.close();
    }

    public static String createTable(DynamoDbClient ddb, String tableName, String key) {
        DynamoDbWaiter dbWaiter = ddb.waiter();
        CreateTableRequest request = CreateTableRequest.builder()
            .attributeDefinitions(AttributeDefinition.builder()
                .attributeName(key)
                .attributeType(ScalarAttributeType.S)
                .build())
            .keySchema(KeySchemaElement.builder()
                .attributeName(key)
                .keyType(KeyType.HASH)
                .build())
            .billingMode(BillingMode.PAY_PER_REQUEST) //  DynamoDB automatically scales based on traffic.
            .tableName(tableName)
            .build();

        String newTable;
        try {
            CreateTableResponse response = ddb.createTable(request);
            DescribeTableRequest tableRequest = DescribeTableRequest.builder()
                .tableName(tableName)
                .build();

            // Wait until the Amazon DynamoDB table is created.
            WaiterResponse<DescribeTableResponse> waiterResponse = dbWaiter.waitUntilTableExists(tableRequest);
            waiterResponse.matched().response().ifPresent(System.out::println);
            newTable = response.tableDescription().tableName();
            return newTable;

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        return "";
    }
}
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/CreateTable)in der *AWS SDK for Java 2.x API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import { CreateTableCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";

const client = new DynamoDBClient({});

export const main = async () => {
  const command = new CreateTableCommand({
    TableName: "EspressoDrinks",
    // For more information about data types,
    // see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes and
    // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.DataTypeDescriptors
    AttributeDefinitions: [
      {
        AttributeName: "DrinkName",
        AttributeType: "S",
      },
    ],
    KeySchema: [
      {
        AttributeName: "DrinkName",
        KeyType: "HASH",
      },
    ],
    BillingMode: "PAY_PER_REQUEST",
  });

  const response = await client.send(command);
  console.log(response);
  return response;
};
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-examples-using-tables.html#dynamodb-examples-using-tables-creating-a-table). 
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/CreateTableCommand)in der *AWS SDK für JavaScript API-Referenz*. 

**SDK für JavaScript (v2)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascript/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });

var params = {
  AttributeDefinitions: [
    {
      AttributeName: "CUSTOMER_ID",
      AttributeType: "N",
    },
    {
      AttributeName: "CUSTOMER_NAME",
      AttributeType: "S",
    },
  ],
  KeySchema: [
    {
      AttributeName: "CUSTOMER_ID",
      KeyType: "HASH",
    },
    {
      AttributeName: "CUSTOMER_NAME",
      KeyType: "RANGE",
    },
  ],
  ProvisionedThroughput: {
    ReadCapacityUnits: 1,
    WriteCapacityUnits: 1,
  },
  TableName: "CUSTOMER_LIST",
  StreamSpecification: {
    StreamEnabled: false,
  },
};

// Call DynamoDB to create the table
ddb.createTable(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Table Created", data);
  }
});
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-examples-using-tables.html#dynamodb-examples-using-tables-creating-a-table). 
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/CreateTable)in der *AWS SDK für JavaScript API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun createNewTable(
    tableNameVal: String,
    key: String,
): String? {
    val attDef =
        AttributeDefinition {
            attributeName = key
            attributeType = ScalarAttributeType.S
        }

    val keySchemaVal =
        KeySchemaElement {
            attributeName = key
            keyType = KeyType.Hash
        }

    val request =
        CreateTableRequest {
            attributeDefinitions = listOf(attDef)
            keySchema = listOf(keySchemaVal)
            billingMode = BillingMode.PayPerRequest
            tableName = tableNameVal
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        var tableArn: String
        val response = ddb.createTable(request)
        ddb.waitUntilTableExists {
            // suspend call
            tableName = tableNameVal
        }
        tableArn = response.tableDescription!!.tableArn.toString()
        println("Table $tableArn is ready")
        return tableArn
    }
}
```
+  API-Details finden Sie [CreateTable](https://sdk.amazonaws.com/kotlin/api/latest/index.html)in der *API-Referenz zum AWS SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 
Erstellen Sie eine -Tabelle.  

```
        $tableName = "ddb_demo_table_$uuid";
        $service->createTable(
            $tableName,
            [
                new DynamoDBAttribute('year', 'N', 'HASH'),
                new DynamoDBAttribute('title', 'S', 'RANGE')
            ]
        );

    public function createTable(string $tableName, array $attributes)
    {
        $keySchema = [];
        $attributeDefinitions = [];
        foreach ($attributes as $attribute) {
            if (is_a($attribute, DynamoDBAttribute::class)) {
                $keySchema[] = ['AttributeName' => $attribute->AttributeName, 'KeyType' => $attribute->KeyType];
                $attributeDefinitions[] =
                    ['AttributeName' => $attribute->AttributeName, 'AttributeType' => $attribute->AttributeType];
            }
        }

        $this->dynamoDbClient->createTable([
            'TableName' => $tableName,
            'KeySchema' => $keySchema,
            'AttributeDefinitions' => $attributeDefinitions,
            'ProvisionedThroughput' => ['ReadCapacityUnits' => 10, 'WriteCapacityUnits' => 10],
        ]);
    }
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/CreateTable)in der *AWS SDK für PHP API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: In diesem Beispiel wird eine Tabelle mit dem Namen Thread erstellt, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp-Hash) und 'Subject' (Schlüsseltypbereich) besteht. Das zur Erstellung der Tabelle verwendete Schema kann wie gezeigt an jedes Cmdlet übergeben oder mit dem Parameter „-Schema“ angegeben werden.**  

```
$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
```
**Ausgabe:**  

```
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  : {}
```
**Beispiel 2: In diesem Beispiel wird eine Tabelle mit dem Namen Thread erstellt, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp-Hash) und 'Subject' (Schlüsseltypbereich) besteht. Ein lokaler sekundärer Index wird ebenfalls definiert. Der Schlüssel des lokalen sekundären Indexes wird automatisch anhand des primären Hashschlüssels in der Tabelle (ForumName) festgelegt. Das zur Erstellung der Tabelle verwendete Schema kann wie gezeigt an jedes Cmdlet übergeben oder mit dem Parameter „-Schema“ angegeben werden.**  

```
$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
```
**Ausgabe:**  

```
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}
```
**Beispiel 3: Dieses Beispiel zeigt, wie eine einzelne Pipeline verwendet wird, um eine Tabelle mit dem Namen Thread zu erstellen, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp Hash) und 'Subject' (Schlüsseltypbereich) und einem lokalen sekundären Index besteht. Mit den Optionen „Add- DDBKey Schema“ und DDBIndex „Add- Schema“ wird ein neues TableSchema Objekt für Sie erstellt, falls keines über die Pipeline oder den Parameter -Schema bereitgestellt wird.**  

```
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
```
**Ausgabe:**  

```
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}
```
+  Einzelheiten zur API finden Sie unter [CreateTable AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v4/reference)*Cmdlet-Referenz (*V4). 

**Tools für V5 PowerShell **  
**Beispiel 1: In diesem Beispiel wird eine Tabelle mit dem Namen Thread erstellt, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp-Hash) und 'Subject' (Schlüsseltypbereich) besteht. Das zur Erstellung der Tabelle verwendete Schema kann wie gezeigt an jedes Cmdlet übergeben oder mit dem Parameter „-Schema“ angegeben werden.**  

```
$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
```
**Ausgabe:**  

```
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  : {}
```
**Beispiel 2: In diesem Beispiel wird eine Tabelle mit dem Namen Thread erstellt, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp-Hash) und 'Subject' (Schlüsseltypbereich) besteht. Ein lokaler sekundärer Index wird ebenfalls definiert. Der Schlüssel des lokalen sekundären Indexes wird automatisch anhand des primären Hashschlüssels in der Tabelle (ForumName) festgelegt. Das zur Erstellung der Tabelle verwendete Schema kann wie gezeigt an jedes Cmdlet übergeben oder mit dem Parameter „-Schema“ angegeben werden.**  

```
$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
```
**Ausgabe:**  

```
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}
```
**Beispiel 3: Dieses Beispiel zeigt, wie eine einzelne Pipeline verwendet wird, um eine Tabelle mit dem Namen Thread zu erstellen, deren Primärschlüssel aus 'ForumName' (Schlüsseltyp Hash) und 'Subject' (Schlüsseltypbereich) und einem lokalen sekundären Index besteht. Mit den Optionen „Add- DDBKey Schema“ und DDBIndex „Add- Schema“ wird ein neues TableSchema Objekt für Sie erstellt, falls keines über die Pipeline oder den Parameter -Schema bereitgestellt wird.**  

```
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
```
**Ausgabe:**  

```
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}
```
+  Einzelheiten zur API finden Sie unter [CreateTable AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v5/reference)*Cmdlet-Referenz (*V5). 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 
Erstellen Sie eine Tabelle zum Speichern von Filmdaten.  

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def create_table(self, table_name):
        """
        Creates an Amazon DynamoDB table that can be used to store movie data.
        The table uses the release year of the movie as the partition key and the
        title as the sort key.

        :param table_name: The name of the table to create.
        :return: The newly created table.
        """
        try:
            self.table = self.dyn_resource.create_table(
                TableName=table_name,
                KeySchema=[
                    {"AttributeName": "year", "KeyType": "HASH"},  # Partition key
                    {"AttributeName": "title", "KeyType": "RANGE"},  # Sort key
                ],
                AttributeDefinitions=[
                    {"AttributeName": "year", "AttributeType": "N"},
                    {"AttributeName": "title", "AttributeType": "S"},
                ],
                BillingMode='PAY_PER_REQUEST',
            )
            self.table.wait_until_exists()
        except ClientError as err:
            logger.error(
                "Couldn't create table %s. Here's why: %s: %s",
                table_name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return self.table
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/CreateTable)in *AWS SDK for Python (Boto3) API* Reference. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
# Encapsulates an Amazon DynamoDB table of movie data.
class Scaffold
  attr_reader :dynamo_resource, :table_name, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table_name = table_name
    @table = nil
    @logger = Logger.new($stdout)
    @logger.level = Logger::DEBUG
  end

  # Creates an Amazon DynamoDB table that can be used to store movie data.
  # The table uses the release year of the movie as the partition key and the
  # title as the sort key.
  #
  # @param table_name [String] The name of the table to create.
  # @return [Aws::DynamoDB::Table] The newly created table.
  def create_table(table_name)
    @table = @dynamo_resource.create_table(
      table_name: table_name,
      key_schema: [
        { attribute_name: 'year', key_type: 'HASH' }, # Partition key
        { attribute_name: 'title', key_type: 'RANGE' } # Sort key
      ],
      attribute_definitions: [
        { attribute_name: 'year', attribute_type: 'N' },
        { attribute_name: 'title', attribute_type: 'S' }
      ],
      billing_mode: 'PAY_PER_REQUEST'
    )
    @dynamo_resource.client.wait_until(:table_exists, table_name: table_name)
    @table
  rescue Aws::DynamoDB::Errors::ServiceError => e
    @logger.error("Failed create table #{table_name}:\n#{e.code}: #{e.message}")
    raise
  end
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/CreateTable)in der *AWS SDK für Ruby API-Referenz*. 

------
#### [ Rust ]

**SDK für Rust**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/dynamodb#code-examples) einrichten und ausführen. 

```
pub async fn create_table(
    client: &Client,
    table: &str,
    key: &str,
) -> Result<CreateTableOutput, Error> {
    let a_name: String = key.into();
    let table_name: String = table.into();

    let ad = AttributeDefinition::builder()
        .attribute_name(&a_name)
        .attribute_type(ScalarAttributeType::S)
        .build()
        .map_err(Error::BuildError)?;

    let ks = KeySchemaElement::builder()
        .attribute_name(&a_name)
        .key_type(KeyType::Hash)
        .build()
        .map_err(Error::BuildError)?;

    let create_table_response = client
        .create_table()
        .table_name(table_name)
        .key_schema(ks)
        .attribute_definitions(ad)
        .billing_mode(BillingMode::PayPerRequest)
        .send()
        .await;

    match create_table_response {
        Ok(out) => {
            println!("Added table {} with key {}", table, key);
            Ok(out)
        }
        Err(e) => {
            eprintln!("Got an error creating table:");
            eprintln!("{}", e);
            Err(Error::unhandled(e))
        }
    }
}
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.rs/aws-sdk-dynamodb/latest/aws_sdk_dynamodb/client/struct.Client.html#method.create_table)in der *API-Referenz zum AWS SDK für Rust*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        DATA(lt_keyschema) = VALUE /aws1/cl_dynkeyschemaelement=>tt_keyschema(
          ( NEW /aws1/cl_dynkeyschemaelement( iv_attributename = 'year'
                                              iv_keytype = 'HASH' ) )
          ( NEW /aws1/cl_dynkeyschemaelement( iv_attributename = 'title'
                                              iv_keytype = 'RANGE' ) ) ).
        DATA(lt_attributedefinitions) = VALUE /aws1/cl_dynattributedefn=>tt_attributedefinitions(
          ( NEW /aws1/cl_dynattributedefn( iv_attributename = 'year'
                                           iv_attributetype = 'N' ) )
          ( NEW /aws1/cl_dynattributedefn( iv_attributename = 'title'
                                           iv_attributetype = 'S' ) ) ).

        " Adjust read/write capacities as desired.
        DATA(lo_dynprovthroughput)  = NEW /aws1/cl_dynprovthroughput(
          iv_readcapacityunits = 5
          iv_writecapacityunits = 5 ).
        oo_result = lo_dyn->createtable(
          it_keyschema = lt_keyschema
          iv_tablename = iv_table_name
          it_attributedefinitions = lt_attributedefinitions
          io_provisionedthroughput = lo_dynprovthroughput ).
        " Table creation can take some time. Wait till table exists before returning.
        lo_dyn->get_waiter( )->tableexists(
          iv_max_wait_time = 200
          iv_tablename     = iv_table_name ).
        MESSAGE 'DynamoDB Table' && iv_table_name && 'created.' TYPE 'I'.
        " This exception can happen if the table already exists.
      CATCH /aws1/cx_dynresourceinuseex INTO DATA(lo_resourceinuseex).
        DATA(lv_error) = |"{ lo_resourceinuseex->av_err_code }" - { lo_resourceinuseex->av_err_msg }|.
        MESSAGE lv_error TYPE 'E'.
    ENDTRY.
```
+  Einzelheiten zur API finden Sie [CreateTable](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    ///
    /// Create a movie table in the Amazon DynamoDB data store.
    ///
    private func createTable() async throws {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            let input = CreateTableInput(
                attributeDefinitions: [
                    DynamoDBClientTypes.AttributeDefinition(attributeName: "year", attributeType: .n),
                    DynamoDBClientTypes.AttributeDefinition(attributeName: "title", attributeType: .s)
                ],
                billingMode: DynamoDBClientTypes.BillingMode.payPerRequest,
                keySchema: [
                    DynamoDBClientTypes.KeySchemaElement(attributeName: "year", keyType: .hash),
                    DynamoDBClientTypes.KeySchemaElement(attributeName: "title", keyType: .range)
                ],
                tableName: self.tableName
            )
            let output = try await client.createTable(input: input)
            if output.tableDescription == nil {
                throw MoviesError.TableNotFound
            }
        } catch {
            print("ERROR: createTable:", dump(error))
            throw error
        }
    }
```
+  Einzelheiten zur API finden Sie [CreateTable](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/createtable(input:))in der *API-Referenz zum AWS SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

Fahren Sie nach dem Erstellen der neuen Tabelle mit [Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle](getting-started-step-2.md) fort.

# Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle
<a name="getting-started-step-2"></a>

In diesem Schritt fügen Sie mehrere Elemente in die Tabelle `Music` ein, die Sie in [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md) erstellt haben. 

Weitere Informationen über Schreibvorgänge finden Sie unter [Schreiben eines Elements](WorkingWithItems.md#WorkingWithItems.WritingData).

## AWS-Managementkonsole
<a name="getting-started-step-2-Console"></a>

Gehen Sie wie folgt vor, um mithilfe der DynamoDB-Konsole Daten in die `Music`-Tabelle zu schreiben.

1. Öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus. 

1. Wählen Sie auf der Seite **Tabellen** die Tabelle **Musik** aus.

1. Wählen Sie **Tabellenelemente erkunden** aus.

1. Wählen Sie im Abschnitt **Zurückgegebene Elemente** die Option **Element erstellen** aus.

1. Gehen Sie auf der Seite **Element erstellen** wie folgt vor, um Elemente zur Tabelle hinzuzufügen:

   1. Klicken Sie auf **Neues Attribut hinzufügen** und wählen Sie dann **Zahl** aus.

   1. Geben Sie als Attributnamen den Wert **Awards** ein.

   1. Wiederholen Sie diesen Vorgang, um ein **AlbumTitle** vom Typ **String** zu erstellen.

   1. Geben Sie die folgenden Werte für Ihr Element ein:

      1. Machen Sie für **Artist** die Eingabe **No One You Know**.

      1. Geben Sie unter **SongTitle** den Wert **Call Me Today** ein.

      1. Geben Sie unter **AlbumTitle** den Wert **Somewhat Famous** ein.

      1. Machen Sie für **Awards** die Eingabe **1**.

1. Wählen Sie **Create item** (Element erstellen) aus.

1. Wiederholen Sie diesen Vorgang und erstellen Sie ein anderes Element mit den folgenden Werten:

   1. Machen Sie für **Artist** die Eingabe **Acme Band**.

   1. Zum **SongTitle**Eingeben. **Happy Day**

   1. Geben Sie unter **AlbumTitle** den Wert **Songs About Life** ein.

   1. Machen Sie für **Awards** die Eingabe **10**.

1. Tun Sie dies noch einmal, um ein anderes Element mit demselben **Artist** wie im vorherigen Schritt, aber andere Werte für die anderen Attribute zu erstellen:

   1. Machen Sie für **Artist** die Eingabe **Acme Band**.

   1. Zum **SongTitle**Eingeben**PartiQL Rocks**.

   1. Geben Sie unter **AlbumTitle** den Wert **Another Album Title** ein.

   1. Machen Sie für **Awards** die Eingabe **8**.

## AWS CLI
<a name="getting-started-step-2-CLI"></a>

Im folgenden AWS CLI Beispiel werden mehrere neue Elemente in der `Music` Tabelle erstellt. Sie können dies entweder über die DynamoDB-API tun oder [PartiQL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html), eine SQL-kompatible Abfragesprache für DynamoDB.

------
#### [ DynamoDB API ]

**Linux**

```
aws dynamodb put-item \
    --table-name Music  \
    --item \
        '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}'

aws dynamodb put-item \
    --table-name Music  \
    --item \
        '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Howdy"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "2"}}'

aws dynamodb put-item \
    --table-name Music \
    --item \
        '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}}'
                            
aws dynamodb put-item \
    --table-name Music \
    --item \
        '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "PartiQL Rocks"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}}'
```

**Windows CMD**

```
aws dynamodb put-item ^
    --table-name Music  ^
    --item ^
        "{\"Artist\": {\"S\": \"No One You Know\"}, \"SongTitle\": {\"S\": \"Call Me Today\"}, \"AlbumTitle\": {\"S\": \"Somewhat Famous\"}, \"Awards\": {\"N\": \"1\"}}"

aws dynamodb put-item ^
    --table-name Music  ^
    --item ^
        "{\"Artist\": {\"S\": \"No One You Know\"}, \"SongTitle\": {\"S\": \"Howdy\"}, \"AlbumTitle\": {\"S\": \"Somewhat Famous\"}, \"Awards\": {\"N\": \"2\"}}"

aws dynamodb put-item ^
    --table-name Music ^
    --item ^
        "{\"Artist\": {\"S\": \"Acme Band\"}, \"SongTitle\": {\"S\": \"Happy Day\"}, \"AlbumTitle\": {\"S\": \"Songs About Life\"}, \"Awards\": {\"N\": \"10\"}}"
                            
aws dynamodb put-item ^
    --table-name Music ^
    --item ^
        "{\"Artist\": {\"S\": \"Acme Band\"}, \"SongTitle\": {\"S\": \"PartiQL Rocks\"}, \"AlbumTitle\": {\"S\": \"Another Album Title\"}, \"Awards\": {\"N\": \"8\"}}"
```

------
#### [ PartiQL for DynamoDB ]

**Linux**

```
aws dynamodb execute-statement --statement "INSERT INTO Music  \
                VALUE  \
                {'Artist':'No One You Know','SongTitle':'Call Me Today', 'AlbumTitle':'Somewhat Famous', 'Awards':'1'}"

aws dynamodb execute-statement --statement "INSERT INTO Music  \
                VALUE  \
                {'Artist':'No One You Know','SongTitle':'Howdy', 'AlbumTitle':'Somewhat Famous', 'Awards':'2'}"

aws dynamodb execute-statement --statement "INSERT INTO Music  \
                VALUE  \
                {'Artist':'Acme Band','SongTitle':'Happy Day', 'AlbumTitle':'Songs About Life', 'Awards':'10'}"
                            
aws dynamodb execute-statement --statement "INSERT INTO Music  \
                VALUE  \
                {'Artist':'Acme Band','SongTitle':'PartiQL Rocks', 'AlbumTitle':'Another Album Title', 'Awards':'8'}"
```

**Windows CMD**

```
aws dynamodb execute-statement --statement "INSERT INTO Music VALUE {'Artist':'No One You Know','SongTitle':'Call Me Today', 'AlbumTitle':'Somewhat Famous', 'Awards':'1'}"

aws dynamodb execute-statement --statement "INSERT INTO Music VALUE {'Artist':'No One You Know','SongTitle':'Howdy', 'AlbumTitle':'Somewhat Famous', 'Awards':'2'}"

aws dynamodb execute-statement --statement "INSERT INTO Music VALUE {'Artist':'Acme Band','SongTitle':'Happy Day', 'AlbumTitle':'Songs About Life', 'Awards':'10'}"
                            
aws dynamodb execute-statement --statement "INSERT INTO Music VALUE {'Artist':'Acme Band','SongTitle':'PartiQL Rocks', 'AlbumTitle':'Another Album Title', 'Awards':'8'}"
```

Für weitere Informationen zum Schreiben von Daten mit PartiQL siehe [PartiQL Insert Statements (PartiQL-Insert-Anweisungen)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.insert.html).

------

Weitere Informationen zu unterstützten Datentypen in DynamoDB finden Sie unter [Datentypen](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes). 

Weitere Informationen zur Darstellung von DynamoDB-Datentypen in JSON finden Sie unter [Attributwerte](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html). 

## AWS SDK
<a name="getting-started-step-2-SDK"></a>

Die folgenden Codebeispiele zeigen, wie ein Element mithilfe eines SDK in eine DynamoDB-Tabelle geschrieben wird. AWS 

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Adds a new item to the table.
    /// </summary>
    /// <param name="newMovie">A Movie object containing informtation for
    /// the movie to add to the table.</param>
    /// <param name="tableName">The name of the table where the item will be added.</param>
    /// <returns>A Boolean value that indicates the results of adding the item.</returns>
    public async Task<bool> PutItemAsync(Movie newMovie, string tableName)
    {
        try
        {
            var item = new Dictionary<string, AttributeValue>
            {
                ["title"] = new AttributeValue { S = newMovie.Title },
                ["year"] = new AttributeValue { N = newMovie.Year.ToString() },
            };

            var request = new PutItemRequest
            {
                TableName = tableName,
                Item = item,
            };

            await _amazonDynamoDB.PutItemAsync(request);
            return true;
        }
        catch (ResourceNotFoundException ex)
        {
            Console.WriteLine($"Table {tableName} was not found. {ex.Message}");
            return false;
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while putting item. {ex.Message}");
            throw;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while putting item. {ex.Message}");
            throw;
        }
    }
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/PutItem)in der *AWS SDK für .NET API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
##############################################################################
# function dynamodb_put_item
#
# This function puts an item into a DynamoDB table.
#
# Parameters:
#       -n table_name  -- The name of the table.
#       -i item  -- Path to json file containing the item values.
#
#  Returns:
#       0 - If successful.
#       1 - If it fails.
##############################################################################
function dynamodb_put_item() {
  local table_name item response
  local option OPTARG # Required to use getopts command in a function.

  #######################################
  # Function usage explanation
  #######################################
  function usage() {
    echo "function dynamodb_put_item"
    echo "Put an item into a DynamoDB table."
    echo " -n table_name  -- The name of the table."
    echo " -i item  -- Path to json file containing the item values."
    echo ""
  }

  while getopts "n:i:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      i) item="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  if [[ -z "$item" ]]; then
    errecho "ERROR: You must provide an item with the -i parameter."
    usage
    return 1
  fi

  iecho "Parameters:\n"
  iecho "    table_name:   $table_name"
  iecho "    item:   $item"
  iecho ""
  iecho ""

  response=$(aws dynamodb put-item \
    --table-name "$table_name" \
    --item file://"$item")

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports put-item operation failed.$response"
    return 1
  fi

  return 0

}
```
Die in diesem Beispiel verwendeten Hilfsfunktionen.  

```
###############################################################################
# function iecho
#
# This function enables the script to display the specified text only if
# the global variable $VERBOSE is set to true.
###############################################################################
function iecho() {
  if [[ $VERBOSE == true ]]; then
    echo "$@"
  fi
}

###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/PutItem)in der *AWS CLI Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Put an item in an Amazon DynamoDB table.
/*!
  \sa putItem()
  \param tableName: The table name.
  \param artistKey: The artist key. This is the partition key for the table.
  \param artistValue: The artist value.
  \param albumTitleKey: The album title key.
  \param albumTitleValue: The album title value.
  \param awardsKey: The awards key.
  \param awardsValue: The awards value.
  \param songTitleKey: The song title key.
  \param songTitleValue: The song title value.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
 */
bool AwsDoc::DynamoDB::putItem(const Aws::String &tableName,
                               const Aws::String &artistKey,
                               const Aws::String &artistValue,
                               const Aws::String &albumTitleKey,
                               const Aws::String &albumTitleValue,
                               const Aws::String &awardsKey,
                               const Aws::String &awardsValue,
                               const Aws::String &songTitleKey,
                               const Aws::String &songTitleValue,
                               const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);

    Aws::DynamoDB::Model::PutItemRequest putItemRequest;
    putItemRequest.SetTableName(tableName);

    putItemRequest.AddItem(artistKey, Aws::DynamoDB::Model::AttributeValue().SetS(
            artistValue)); // This is the hash key.
    putItemRequest.AddItem(albumTitleKey, Aws::DynamoDB::Model::AttributeValue().SetS(
            albumTitleValue));
    putItemRequest.AddItem(awardsKey,
                           Aws::DynamoDB::Model::AttributeValue().SetS(awardsValue));
    putItemRequest.AddItem(songTitleKey,
                           Aws::DynamoDB::Model::AttributeValue().SetS(songTitleValue));

    const Aws::DynamoDB::Model::PutItemOutcome outcome = dynamoClient.PutItem(
            putItemRequest);
    if (outcome.IsSuccess()) {
        std::cout << "Successfully added Item!" << std::endl;
    }
    else {
        std::cerr << outcome.GetError().GetMessage() << std::endl;
        return false;
    }

    return waitTableActive(tableName, dynamoClient);
}
```
Code, der darauf wartet, dass die Tabelle aktiv wird.  

```
//! Query a newly created DynamoDB table until it is active.
/*!
  \sa waitTableActive()
  \param waitTableActive: The DynamoDB table's name.
  \param dynamoClient: A DynamoDB client.
  \return bool: Function succeeded.
*/
bool AwsDoc::DynamoDB::waitTableActive(const Aws::String &tableName,
                                       const Aws::DynamoDB::DynamoDBClient &dynamoClient) {

    // Repeatedly call DescribeTable until table is ACTIVE.
    const int MAX_QUERIES = 20;
    Aws::DynamoDB::Model::DescribeTableRequest request;
    request.SetTableName(tableName);

    int count = 0;
    while (count < MAX_QUERIES) {
        const Aws::DynamoDB::Model::DescribeTableOutcome &result = dynamoClient.DescribeTable(
                request);
        if (result.IsSuccess()) {
            Aws::DynamoDB::Model::TableStatus status = result.GetResult().GetTable().GetTableStatus();

            if (Aws::DynamoDB::Model::TableStatus::ACTIVE != status) {
                std::this_thread::sleep_for(std::chrono::seconds(1));
            }
            else {
                return true;
            }
        }
        else {
            std::cerr << "Error DynamoDB::waitTableActive "
                      << result.GetError().GetMessage() << std::endl;
            return false;
        }
        count++;
    }
    return false;
}
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/PutItem)in der *AWS SDK für C\$1\$1 API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**Beispiel 1: So fügen Sie ein Element zu einer Tabelle hinzu**  
Das folgende `put-item` Beispiel fügt der *MusicCollection*Tabelle ein neues Element hinzu.  

```
aws dynamodb put-item \
    --table-name MusicCollection \
    --item file://item.json \
    --return-consumed-capacity TOTAL \
    --return-item-collection-metrics SIZE
```
Inhalt von `item.json`:  

```
{
    "Artist": {"S": "No One You Know"},
    "SongTitle": {"S": "Call Me Today"},
    "AlbumTitle": {"S": "Greatest Hits"}
}
```
Ausgabe:  

```
{
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 1.0
    },
    "ItemCollectionMetrics": {
        "ItemCollectionKey": {
            "Artist": {
                "S": "No One You Know"
            }
        },
        "SizeEstimateRangeGB": [
            0.0,
            1.0
        ]
    }
}
```
Weitere Informationen finden Sie unter [Schreiben eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.WritingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 2: So überschreiben Sie ein Element in einer Tabelle bedingungsabhängig**  
Im folgenden Beispiel für `put-item` wird ein vorhandenes Element in der `MusicCollection`-Tabelle nur dann überschrieben, wenn dieses vorhandene Element ein `AlbumTitle`-Attribut mit dem Wert `Greatest Hits` hat. Der Befehl gibt den vorherigen Wert des Elements zurück.  

```
aws dynamodb put-item \
    --table-name MusicCollection \
    --item file://item.json \
    --condition-expression "#A = :A" \
    --expression-attribute-names file://names.json \
    --expression-attribute-values file://values.json \
    --return-values ALL_OLD
```
Inhalt von `item.json`:  

```
{
    "Artist": {"S": "No One You Know"},
    "SongTitle": {"S": "Call Me Today"},
    "AlbumTitle": {"S": "Somewhat Famous"}
}
```
Inhalt von `names.json`:  

```
{
    "#A": "AlbumTitle"
}
```
Inhalt von `values.json`:  

```
{
    ":A": {"S": "Greatest Hits"}
}
```
Ausgabe:  

```
{
    "Attributes": {
        "AlbumTitle": {
            "S": "Greatest Hits"
        },
        "Artist": {
            "S": "No One You Know"
        },
        "SongTitle": {
            "S": "Call Me Today"
        }
    }
}
```
Wenn der Schlüssel bereits existiert, sollten Sie die folgende Ausgabe sehen:  

```
A client error (ConditionalCheckFailedException) occurred when calling the PutItem operation: The conditional request failed.
```
Weitere Informationen finden Sie unter [Schreiben eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.WritingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Einzelheiten zur API finden Sie [PutItem](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/put-item.html)unter *AWS CLI Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// AddMovie adds a movie the DynamoDB table.
func (basics TableBasics) AddMovie(ctx context.Context, movie Movie) error {
	item, err := attributevalue.MarshalMap(movie)
	if err != nil {
		panic(err)
	}
	_, err = basics.DynamoDbClient.PutItem(ctx, &dynamodb.PutItemInput{
		TableName: aws.String(basics.TableName), Item: item,
	})
	if err != nil {
		log.Printf("Couldn't add item to table. Here's why: %v\n", err)
	}
	return err
}
```
Definieren Sie eine Movie-Struktur, die in diesem Beispiel verwendet wird.  

```
import (
	"archive/zip"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// Movie encapsulates data about a movie. Title and Year are the composite primary key
// of the movie in Amazon DynamoDB. Title is the sort key, Year is the partition key,
// and Info is additional data.
type Movie struct {
	Title string                 `dynamodbav:"title"`
	Year  int                    `dynamodbav:"year"`
	Info  map[string]interface{} `dynamodbav:"info"`
}

// GetKey returns the composite primary key of the movie in a format that can be
// sent to DynamoDB.
func (movie Movie) GetKey() map[string]types.AttributeValue {
	title, err := attributevalue.Marshal(movie.Title)
	if err != nil {
		panic(err)
	}
	year, err := attributevalue.Marshal(movie.Year)
	if err != nil {
		panic(err)
	}
	return map[string]types.AttributeValue{"title": title, "year": year}
}

// String returns the title, year, rating, and plot of a movie, formatted for the example.
func (movie Movie) String() string {
	return fmt.Sprintf("%v\n\tReleased: %v\n\tRating: %v\n\tPlot: %v\n",
		movie.Title, movie.Year, movie.Info["rating"], movie.Info["plot"])
}
```
+  Einzelheiten zur API finden Sie [PutItem](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.PutItem)in der *AWS SDK für Go API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 
Fügt ein Element in eine Tabelle ein mit [DynamoDbClient](https://docs.aws.amazon.com/sdk-for-java/latest/reference/software/amazon/awssdk/services/dynamodb/DynamoDbClient.html).  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.PutItemRequest;
import software.amazon.awssdk.services.dynamodb.model.PutItemResponse;
import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException;
import java.util.HashMap;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 *
 * To place items into an Amazon DynamoDB table using the AWS SDK for Java V2,
 * its better practice to use the
 * Enhanced Client. See the EnhancedPutItem example.
 */
public class PutItem {
    public static void main(String[] args) {
        final String usage = """

                Usage:
                    <tableName> <key> <keyVal> <albumtitle> <albumtitleval> <awards> <awardsval> <Songtitle> <songtitleval>

                Where:
                    tableName - The Amazon DynamoDB table in which an item is placed (for example, Music3).
                    key - The key used in the Amazon DynamoDB table (for example, Artist).
                    keyval - The key value that represents the item to get (for example, Famous Band).
                    albumTitle - The Album title (for example, AlbumTitle).
                    AlbumTitleValue - The name of the album (for example, Songs About Life ).
                    Awards - The awards column (for example, Awards).
                    AwardVal - The value of the awards (for example, 10).
                    SongTitle - The song title (for example, SongTitle).
                    SongTitleVal - The value of the song title (for example, Happy Day).
                **Warning** This program will  place an item that you specify into a table!
                """;

        if (args.length != 9) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        String key = args[1];
        String keyVal = args[2];
        String albumTitle = args[3];
        String albumTitleValue = args[4];
        String awards = args[5];
        String awardVal = args[6];
        String songTitle = args[7];
        String songTitleVal = args[8];

        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();

        putItemInTable(ddb, tableName, key, keyVal, albumTitle, albumTitleValue, awards, awardVal, songTitle,
                songTitleVal);
        System.out.println("Done!");
        ddb.close();
    }

    public static void putItemInTable(DynamoDbClient ddb,
            String tableName,
            String key,
            String keyVal,
            String albumTitle,
            String albumTitleValue,
            String awards,
            String awardVal,
            String songTitle,
            String songTitleVal) {

        HashMap<String, AttributeValue> itemValues = new HashMap<>();
        itemValues.put(key, AttributeValue.builder().s(keyVal).build());
        itemValues.put(songTitle, AttributeValue.builder().s(songTitleVal).build());
        itemValues.put(albumTitle, AttributeValue.builder().s(albumTitleValue).build());
        itemValues.put(awards, AttributeValue.builder().s(awardVal).build());

        PutItemRequest request = PutItemRequest.builder()
                .tableName(tableName)
                .item(itemValues)
                .build();

        try {
            PutItemResponse response = ddb.putItem(request);
            System.out.println(tableName + " was successfully updated. The request id is "
                    + response.responseMetadata().requestId());

        } catch (ResourceNotFoundException e) {
            System.err.format("Error: The Amazon DynamoDB table \"%s\" can't be found.\n", tableName);
            System.err.println("Be sure that it exists and that you've typed its name correctly!");
            System.exit(1);
        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
    }
}
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/PutItem)unter *AWS SDK for Java 2.x API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 
In diesem Beispiel wird der Dokument-Client verwendet, um die Arbeit mit Elementen in DynamoDB zu vereinfachen. Einzelheiten zur API finden Sie unter [PutCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/Class/PutCommand/).  

```
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { PutCommand, DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

export const main = async () => {
  const command = new PutCommand({
    TableName: "HappyAnimals",
    Item: {
      CommonName: "Shiba Inu",
    },
  });

  const response = await docClient.send(command);
  console.log(response);
  return response;
};
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/PutItemCommand)unter *AWS SDK für JavaScript API-Referenz*. 

**SDK für JavaScript (v2)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascript/example_code/dynamodb#code-examples) einrichten und ausführen. 
Fügen Sie ein Element in eine Tabelle ein.  

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });

var params = {
  TableName: "CUSTOMER_LIST",
  Item: {
    CUSTOMER_ID: { N: "001" },
    CUSTOMER_NAME: { S: "Richard Roe" },
  },
};

// Call DynamoDB to add the item to the table
ddb.putItem(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data);
  }
});
```
Fügen Sie ein Element mithilfe des DynamoDB-Dokument-Clients in eine Tabelle ein.  

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create DynamoDB document client
var docClient = new AWS.DynamoDB.DocumentClient({ apiVersion: "2012-08-10" });

var params = {
  TableName: "TABLE",
  Item: {
    HASHKEY: VALUE,
    ATTRIBUTE_1: "STRING_VALUE",
    ATTRIBUTE_2: VALUE_2,
  },
};

docClient.put(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data);
  }
});
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-table-read-write.html#dynamodb-example-table-read-write-writing-an-item). 
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/PutItem)in der *AWS SDK für JavaScript API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun putItemInTable(
    tableNameVal: String,
    key: String,
    keyVal: String,
    albumTitle: String,
    albumTitleValue: String,
    awards: String,
    awardVal: String,
    songTitle: String,
    songTitleVal: String,
) {
    val itemValues = mutableMapOf<String, AttributeValue>()

    // Add all content to the table.
    itemValues[key] = AttributeValue.S(keyVal)
    itemValues[songTitle] = AttributeValue.S(songTitleVal)
    itemValues[albumTitle] = AttributeValue.S(albumTitleValue)
    itemValues[awards] = AttributeValue.S(awardVal)

    val request =
        PutItemRequest {
            tableName = tableNameVal
            item = itemValues
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        ddb.putItem(request)
        println(" A new item was placed into $tableNameVal.")
    }
}
```
+  API-Details finden Sie [PutItem](https://sdk.amazonaws.com/kotlin/api/latest/index.html)in der *API-Referenz zum AWS SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
        echo "What's the name of the last movie you watched?\n";
        while (empty($movieName)) {
            $movieName = testable_readline("Movie name: ");
        }
        echo "And what year was it released?\n";
        $movieYear = "year";
        while (!is_numeric($movieYear) || intval($movieYear) != $movieYear) {
            $movieYear = testable_readline("Year released: ");
        }

        $service->putItem([
            'Item' => [
                'year' => [
                    'N' => "$movieYear",
                ],
                'title' => [
                    'S' => $movieName,
                ],
            ],
            'TableName' => $tableName,
        ]);

    public function putItem(array $array)
    {
        $this->dynamoDbClient->putItem($array);
    }
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/PutItem)in der *AWS SDK für PHP API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: Erstellt ein neues Element oder ersetzt ein vorhandenes Element durch ein neues.**  

```
$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
```
+  Einzelheiten zur API finden Sie unter [PutItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v4/reference)*Cmdlet-Referenz (V4).* 

**Tools für V5 PowerShell **  
**Beispiel 1: Erstellt ein neues Element oder ersetzt ein vorhandenes Element durch ein neues.**  

```
$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
```
+  Einzelheiten zur API finden Sie unter [PutItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v5/reference)*Cmdlet-Referenz (*V5). 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def add_movie(self, title, year, plot, rating):
        """
        Adds a movie to the table.

        :param title: The title of the movie.
        :param year: The release year of the movie.
        :param plot: The plot summary of the movie.
        :param rating: The quality rating of the movie.
        """
        try:
            self.table.put_item(
                Item={
                    "year": year,
                    "title": title,
                    "info": {"plot": plot, "rating": Decimal(str(rating))},
                }
            )
        except ClientError as err:
            logger.error(
                "Couldn't add movie %s to table %s. Here's why: %s: %s",
                title,
                self.table.name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/PutItem)in *AWS SDK for Python (Boto3) API* Reference. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class DynamoDBBasics
  attr_reader :dynamo_resource, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table = @dynamo_resource.table(table_name)
  end

  # Adds a movie to the table.
  #
  # @param movie [Hash] The title, year, plot, and rating of the movie.
  def add_item(movie)
    @table.put_item(
      item: {
        'year' => movie[:year],
        'title' => movie[:title],
        'info' => { 'plot' => movie[:plot], 'rating' => movie[:rating] }
      }
    )
  rescue Aws::DynamoDB::Errors::ServiceError => e
    puts("Couldn't add movie #{title} to table #{@table.name}. Here's why:")
    puts("\t#{e.code}: #{e.message}")
    raise
  end
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/PutItem)in der *AWS SDK für Ruby API-Referenz*. 

------
#### [ Rust ]

**SDK für Rust**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/dynamodb#code-examples) einrichten und ausführen. 

```
pub async fn add_item(client: &Client, item: Item, table: &String) -> Result<ItemOut, Error> {
    let user_av = AttributeValue::S(item.username);
    let type_av = AttributeValue::S(item.p_type);
    let age_av = AttributeValue::S(item.age);
    let first_av = AttributeValue::S(item.first);
    let last_av = AttributeValue::S(item.last);

    let request = client
        .put_item()
        .table_name(table)
        .item("username", user_av)
        .item("account_type", type_av)
        .item("age", age_av)
        .item("first_name", first_av)
        .item("last_name", last_av);

    println!("Executing request [{request:?}] to add item...");

    let resp = request.send().await?;

    let attributes = resp.attributes().unwrap();

    let username = attributes.get("username").cloned();
    let first_name = attributes.get("first_name").cloned();
    let last_name = attributes.get("last_name").cloned();
    let age = attributes.get("age").cloned();
    let p_type = attributes.get("p_type").cloned();

    println!(
        "Added user {:?}, {:?} {:?}, age {:?} as {:?} user",
        username, first_name, last_name, age, p_type
    );

    Ok(ItemOut {
        p_type,
        age,
        username,
        first_name,
        last_name,
    })
}
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.rs/aws-sdk-dynamodb/latest/aws_sdk_dynamodb/client/struct.Client.html#method.put_item)in der *API-Referenz zum AWS SDK für Rust*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        DATA(lo_resp) = lo_dyn->putitem(
          iv_tablename = iv_table_name
          it_item      = it_item ).
        MESSAGE '1 row inserted into DynamoDB Table' && iv_table_name TYPE 'I'.
      CATCH /aws1/cx_dyncondalcheckfaile00.
        MESSAGE 'A condition specified in the operation could not be evaluated.' TYPE 'E'.
      CATCH /aws1/cx_dynresourcenotfoundex.
        MESSAGE 'The table or index does not exist' TYPE 'E'.
      CATCH /aws1/cx_dyntransactconflictex.
        MESSAGE 'Another transaction is using the item' TYPE 'E'.
    ENDTRY.
```
+  Einzelheiten zur API finden Sie [PutItem](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    /// Add a movie specified as a `Movie` structure to the Amazon DynamoDB
    /// table.
    ///
    /// - Parameter movie: The `Movie` to add to the table.
    ///
    func add(movie: Movie) async throws {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            // Get a DynamoDB item containing the movie data.
            let item = try await movie.getAsItem()

            // Send the `PutItem` request to Amazon DynamoDB.

            let input = PutItemInput(
                item: item,
                tableName: self.tableName
            )
            _ = try await client.putItem(input: input)
        } catch {
            print("ERROR: add movie:", dump(error))
            throw error
        }
    }


    ///
    /// Return an array mapping attribute names to Amazon DynamoDB attribute
    /// values, representing the contents of the `Movie` record as a DynamoDB
    /// item.
    ///
    /// - Returns: The movie item as an array of type
    ///   `[Swift.String:DynamoDBClientTypes.AttributeValue]`.
    ///
    func getAsItem() async throws -> [Swift.String:DynamoDBClientTypes.AttributeValue]  {
        // Build the item record, starting with the year and title, which are
        // always present.

        var item: [Swift.String:DynamoDBClientTypes.AttributeValue] = [
            "year": .n(String(self.year)),
            "title": .s(self.title)
        ]

        // Add the `info` field with the rating and/or plot if they're
        // available.

        var details: [Swift.String:DynamoDBClientTypes.AttributeValue] = [:]
        if (self.info.rating != nil || self.info.plot != nil) {
            if self.info.rating != nil {
                details["rating"] = .n(String(self.info.rating!))
            }
            if self.info.plot != nil {
                details["plot"] = .s(self.info.plot!)
            }
        }
        item["info"] = .m(details)

        return item
    }
```
+  Einzelheiten zur API finden Sie [PutItem](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/putitem(input:))in der *API-Referenz zum AWS SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

Nachdem Daten in die Tabelle geschrieben wurden, fahren Sie mit [Schritt 3: Lesen von Daten aus einer DynamoDB-Tabelle](getting-started-step-3.md) fort.

# Schritt 3: Lesen von Daten aus einer DynamoDB-Tabelle
<a name="getting-started-step-3"></a>

In diesem Schritt lesen Sie eines der Elemente, die Sie in [Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle](getting-started-step-2.md) erstellt haben. Sie können die DynamoDB-Konsole oder die verwenden, AWS CLI um ein Element aus der `Music` Tabelle zu lesen, indem Sie und angeben`Artist`. `SongTitle` 

Weitere Informationen über Leseoperationen in DynamoDB finden Sie unter [Lesen eines Elements](WorkingWithItems.md#WorkingWithItems.ReadingData). 

## AWS-Managementkonsole
<a name="getting-started-step-3-Console"></a>

Gehen Sie wie folgt vor, um mithilfe der DynamoDB-Konsole Daten aus der `Music`-Tabelle zu lesen.

1. Öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus.

1. Wählen Sie auf der Seite **Tabellen** die Tabelle **Musik** aus.

1. Wählen Sie **Tabellenelemente erkunden** aus.

1. Zeigen Sie auf der Registerkarte **Elemente** die Liste der in der Tabelle gespeicherten Elemente, sortiert nach `Artist` und `SongTitle`, an. Der erste Eintrag in der Liste ist der mit dem **Künstler** namens **Acme Band** und den **SongTitle****PartiQL** Rocks.

## AWS CLI
<a name="getting-started-step-3-CLI"></a>

Das folgende AWS CLI Beispiel liest ein Element aus dem. `Music` Sie können dies entweder über die DynamoDB-API tun oder [PartiQL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html), eine SQL-kompatible Abfragesprache für DynamoDB.

------
#### [ DynamoDB API ]

**Anmerkung**  
Das Standardverhalten für DynamoDB sind schließlich konsistente Lesevorgänge. Nachstehend wird der Parameter `consistent-read` verwendet, um Strongly Consistent-Lesevorgänge zu veranschaulichen.

**Linux**

```
aws dynamodb get-item --consistent-read \
    --table-name Music \
    --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}'
```

**Windows CMD**

```
aws dynamodb get-item --consistent-read ^
    --table-name Music ^
    --key "{\"Artist\": {\"S\": \"Acme Band\"}, \"SongTitle\": {\"S\": \"Happy Day\"}}"
```

Bei Verwenden von `get-item` wird das folgende Beispielergebnis zurückgegeben.

```
{
    "Item": {
        "AlbumTitle": {
            "S": "Songs About Life"
        },
        "Awards": {
            "S": "10"
        },
        "Artist": {
            "S": "Acme Band"
        },
        "SongTitle": {
            "S": "Happy Day"
        }
    }
}
```

------
#### [ PartiQL for DynamoDB ]

**Linux**

```
aws dynamodb execute-statement --statement "SELECT * FROM Music   \
WHERE Artist='Acme Band' AND SongTitle='Happy Day'"
```

**Windows CMD**

```
aws dynamodb execute-statement --statement "SELECT * FROM Music WHERE Artist='Acme Band' AND SongTitle='Happy Day'"
```

Verwendung der PartiQL `Select`-Anweisung gibt das folgende Beispielergebnis zurück.

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Songs About Life"
            },
            "Awards": {
                "S": "10"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "Happy Day"
            }
        }
    ]
}
```

Für weitere Informationen zum Lesen von Daten mit PartiQL siehe [PartiQL Select Statements (PartiQL-Select-Anweisungen)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.SELECT.html).

------

## AWS SDK
<a name="getting-started-step-3-SDK"></a>

Die folgenden Codebeispiele zeigen, wie Sie mithilfe eines SDK ein Element aus einer DynamoDB-Tabelle lesen. AWS 

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Gets information about an existing movie from the table.
    /// </summary>
    /// <param name="newMovie">A Movie object containing information about
    /// the movie to retrieve.</param>
    /// <param name="tableName">The name of the table containing the movie.</param>
    /// <returns>A Dictionary object containing information about the item
    /// retrieved.</returns>
    public async Task<Dictionary<string, AttributeValue>> GetItemAsync(Movie newMovie, string tableName)
    {
        try
        {
            var key = new Dictionary<string, AttributeValue>
            {
                ["title"] = new AttributeValue { S = newMovie.Title },
                ["year"] = new AttributeValue { N = newMovie.Year.ToString() },
            };

            var request = new GetItemRequest
            {
                Key = key,
                TableName = tableName,
            };

            var response = await _amazonDynamoDB.GetItemAsync(request);
            return response.Item;
        }
        catch (ResourceNotFoundException ex)
        {
            Console.WriteLine($"Table {tableName} was not found. {ex.Message}");
            return new Dictionary<string, AttributeValue>();
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while getting item. {ex.Message}");
            throw;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while getting item. {ex.Message}");
            throw;
        }
    }
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/GetItem)in der *AWS SDK für .NET API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
#############################################################################
# function dynamodb_get_item
#
# This function gets an item from a DynamoDB table.
#
# Parameters:
#       -n table_name  -- The name of the table.
#       -k keys  -- Path to json file containing the keys that identify the item to get.
#       [-q query]  -- Optional JMESPath query expression.
#
#  Returns:
#       The item as text output.
#  And:
#       0 - If successful.
#       1 - If it fails.
############################################################################
function dynamodb_get_item() {
  local table_name keys query response
  local option OPTARG # Required to use getopts command in a function.

  # ######################################
  # Function usage explanation
  #######################################
  function usage() {
    echo "function dynamodb_get_item"
    echo "Get an item from a DynamoDB table."
    echo " -n table_name  -- The name of the table."
    echo " -k keys  -- Path to json file containing the keys that identify the item to get."
    echo " [-q query]  -- Optional JMESPath query expression."
    echo ""
  }
  query=""
  while getopts "n:k:q:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      k) keys="${OPTARG}" ;;
      q) query="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  if [[ -z "$keys" ]]; then
    errecho "ERROR: You must provide a keys json file path the -k parameter."
    usage
    return 1
  fi

  if [[ -n "$query" ]]; then
    response=$(aws dynamodb get-item \
      --table-name "$table_name" \
      --key file://"$keys" \
      --output text \
      --query "$query")
  else
    response=$(
      aws dynamodb get-item \
        --table-name "$table_name" \
        --key file://"$keys" \
        --output text
    )
  fi

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports get-item operation failed.$response"
    return 1
  fi

  if [[ -n "$query" ]]; then
    echo "$response" | sed "/^\t/s/\t//1" # Remove initial tab that the JMSEPath query inserts on some strings.
  else
    echo "$response"
  fi

  return 0
}
```
Die in diesem Beispiel verwendeten Hilfsfunktionen.  

```
###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/GetItem)in der *AWS CLI Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Get an item from an Amazon DynamoDB table.
/*!
  \sa getItem()
  \param tableName: The table name.
  \param partitionKey: The partition key.
  \param partitionValue: The value for the partition key.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
 */

bool AwsDoc::DynamoDB::getItem(const Aws::String &tableName,
                               const Aws::String &partitionKey,
                               const Aws::String &partitionValue,
                               const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);
    Aws::DynamoDB::Model::GetItemRequest request;

    // Set up the request.
    request.SetTableName(tableName);
    request.AddKey(partitionKey,
                   Aws::DynamoDB::Model::AttributeValue().SetS(partitionValue));

    // Retrieve the item's fields and values.
    const Aws::DynamoDB::Model::GetItemOutcome &outcome = dynamoClient.GetItem(request);
    if (outcome.IsSuccess()) {
        // Reference the retrieved fields/values.
        const Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue> &item = outcome.GetResult().GetItem();
        if (!item.empty()) {
            // Output each retrieved field and its value.
            for (const auto &i: item)
                std::cout << "Values: " << i.first << ": " << i.second.GetS()
                          << std::endl;
        }
        else {
            std::cout << "No item found with the key " << partitionKey << std::endl;
        }
    }
    else {
        std::cerr << "Failed to get item: " << outcome.GetError().GetMessage();
    }

    return outcome.IsSuccess();
}
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/GetItem)in der *AWS SDK für C\$1\$1 API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**Beispiel 1: So lesen Sie ein Element in einer Tabelle**  
Das folgende Beispiel für `get-item` ruft ein Element aus der `MusicCollection`-Tabelle ab. Die Tabelle hat einen hash-and-range Primärschlüssel (`Artist`und`SongTitle`), daher müssen Sie diese beiden Attribute angeben. Der Befehl fragt auch Informationen über die Lesekapazität ab, die von der Operation verbraucht wird.  

```
aws dynamodb get-item \
    --table-name MusicCollection \
    --key file://key.json \
    --return-consumed-capacity TOTAL
```
Inhalt von `key.json`:  

```
{
    "Artist": {"S": "Acme Band"},
    "SongTitle": {"S": "Happy Day"}
}
```
Ausgabe:  

```
{
    "Item": {
        "AlbumTitle": {
            "S": "Songs About Life"
        },
        "SongTitle": {
            "S": "Happy Day"
        },
        "Artist": {
            "S": "Acme Band"
        }
    },
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 0.5
    }
}
```
Weitere Informationen finden Sie unter [Lesen eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ReadingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 2: So lesen Sie ein Element mit einem konsistenten Lesevorgang**  
Das folgende Beispiel ruft mithilfe von strikt konsistenten Lesevorgängen ein Element aus der `MusicCollection`-Tabelle ab.  

```
aws dynamodb get-item \
    --table-name MusicCollection \
    --key file://key.json \
    --consistent-read \
    --return-consumed-capacity TOTAL
```
Inhalt von `key.json`:  

```
{
    "Artist": {"S": "Acme Band"},
    "SongTitle": {"S": "Happy Day"}
}
```
Ausgabe:  

```
{
    "Item": {
        "AlbumTitle": {
            "S": "Songs About Life"
        },
        "SongTitle": {
            "S": "Happy Day"
        },
        "Artist": {
            "S": "Acme Band"
        }
    },
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 1.0
    }
}
```
Weitere Informationen finden Sie unter [Lesen eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ReadingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 3: So rufen Sie bestimmte Attribute eines Elements ab**  
Im folgenden Beispiel wird ein Projektionsausdruck verwendet, um nur drei Attribute des gewünschten Elements abzurufen.  

```
aws dynamodb get-item \
    --table-name ProductCatalog \
    --key '{"Id": {"N": "102"}}' \
    --projection-expression "#T, #C, #P" \
    --expression-attribute-names file://names.json
```
Inhalt von `names.json`:  

```
{
    "#T": "Title",
    "#C": "ProductCategory",
    "#P": "Price"
}
```
Ausgabe:  

```
{
    "Item": {
        "Price": {
            "N": "20"
        },
        "Title": {
            "S": "Book 102 Title"
        },
        "ProductCategory": {
            "S": "Book"
        }
    }
}
```
Weitere Informationen finden Sie unter [Lesen eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ReadingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Einzelheiten zur API finden Sie [GetItem](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/get-item.html)unter *AWS CLI Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// GetMovie gets movie data from the DynamoDB table by using the primary composite key
// made of title and year.
func (basics TableBasics) GetMovie(ctx context.Context, title string, year int) (Movie, error) {
	movie := Movie{Title: title, Year: year}
	response, err := basics.DynamoDbClient.GetItem(ctx, &dynamodb.GetItemInput{
		Key: movie.GetKey(), TableName: aws.String(basics.TableName),
	})
	if err != nil {
		log.Printf("Couldn't get info about %v. Here's why: %v\n", title, err)
	} else {
		err = attributevalue.UnmarshalMap(response.Item, &movie)
		if err != nil {
			log.Printf("Couldn't unmarshal response. Here's why: %v\n", err)
		}
	}
	return movie, err
}
```
Definieren Sie eine Movie-Struktur, die in diesem Beispiel verwendet wird.  

```
import (
	"archive/zip"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// Movie encapsulates data about a movie. Title and Year are the composite primary key
// of the movie in Amazon DynamoDB. Title is the sort key, Year is the partition key,
// and Info is additional data.
type Movie struct {
	Title string                 `dynamodbav:"title"`
	Year  int                    `dynamodbav:"year"`
	Info  map[string]interface{} `dynamodbav:"info"`
}

// GetKey returns the composite primary key of the movie in a format that can be
// sent to DynamoDB.
func (movie Movie) GetKey() map[string]types.AttributeValue {
	title, err := attributevalue.Marshal(movie.Title)
	if err != nil {
		panic(err)
	}
	year, err := attributevalue.Marshal(movie.Year)
	if err != nil {
		panic(err)
	}
	return map[string]types.AttributeValue{"title": title, "year": year}
}

// String returns the title, year, rating, and plot of a movie, formatted for the example.
func (movie Movie) String() string {
	return fmt.Sprintf("%v\n\tReleased: %v\n\tRating: %v\n\tPlot: %v\n",
		movie.Title, movie.Year, movie.Info["rating"], movie.Info["plot"])
}
```
+  Einzelheiten zur API finden Sie [GetItem](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.GetItem)in der *AWS SDK für Go API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 
Ruft mithilfe von ein Element aus einer Tabelle ab DynamoDbClient.  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 *
 * To get an item from an Amazon DynamoDB table using the AWS SDK for Java V2,
 * its better practice to use the
 * Enhanced Client, see the EnhancedGetItem example.
 */
public class GetItem {
    public static void main(String[] args) {
        final String usage = """

                Usage:
                    <tableName> <key> <keyVal>

                Where:
                    tableName - The Amazon DynamoDB table from which an item is retrieved (for example, Music3).\s
                    key - The key used in the Amazon DynamoDB table (for example, Artist).\s
                    keyval - The key value that represents the item to get (for example, Famous Band).
                """;

        if (args.length != 3) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        String key = args[1];
        String keyVal = args[2];
        System.out.format("Retrieving item \"%s\" from \"%s\"\n", keyVal, tableName);
        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();

        getDynamoDBItem(ddb, tableName, key, keyVal);
        ddb.close();
    }

    public static void getDynamoDBItem(DynamoDbClient ddb, String tableName, String key, String keyVal) {
        HashMap<String, AttributeValue> keyToGet = new HashMap<>();
        keyToGet.put(key, AttributeValue.builder()
                .s(keyVal)
                .build());

        GetItemRequest request = GetItemRequest.builder()
                .key(keyToGet)
                .tableName(tableName)
                .build();

        try {
            // If there is no matching item, GetItem does not return any data.
            Map<String, AttributeValue> returnedItem = ddb.getItem(request).item();
            if (returnedItem.isEmpty())
                System.out.format("No item found with the key %s!\n", key);
            else {
                Set<String> keys = returnedItem.keySet();
                System.out.println("Amazon DynamoDB table attributes: \n");
                for (String key1 : keys) {
                    System.out.format("%s: %s\n", key1, returnedItem.get(key1).toString());
                }
            }

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
    }
}
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/GetItem)unter *AWS SDK for Java 2.x API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 
In diesem Beispiel wird der Dokument-Client verwendet, um die Arbeit mit Elementen in DynamoDB zu vereinfachen. Einzelheiten zur API finden Sie unter [GetCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/Class/GetCommand/).  

```
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

export const main = async () => {
  const command = new GetCommand({
    TableName: "AngryAnimals",
    Key: {
      CommonName: "Shoebill",
    },
  });

  const response = await docClient.send(command);
  console.log(response);
  return response;
};
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/GetItemCommand)unter *AWS SDK für JavaScript API-Referenz*. 

**SDK für JavaScript (v2)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascript/example_code/dynamodb#code-examples) einrichten und ausführen. 
Rufen Sie ein Element aus einer Tabelle ab.  

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });

var params = {
  TableName: "TABLE",
  Key: {
    KEY_NAME: { N: "001" },
  },
  ProjectionExpression: "ATTRIBUTE_NAME",
};

// Call DynamoDB to read the item from the table
ddb.getItem(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Item);
  }
});
```
Rufen Sie ein Element mithilfe des DynamoDB-Dokument-Clients aus einer Tabelle ab.  

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create DynamoDB document client
var docClient = new AWS.DynamoDB.DocumentClient({ apiVersion: "2012-08-10" });

var params = {
  TableName: "EPISODES_TABLE",
  Key: { KEY_NAME: VALUE },
};

docClient.get(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Item);
  }
});
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-dynamodb-utilities.html#dynamodb-example-document-client-get). 
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/GetItem)in der *AWS SDK für JavaScript API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun getSpecificItem(
    tableNameVal: String,
    keyName: String,
    keyVal: String,
) {
    val keyToGet = mutableMapOf<String, AttributeValue>()
    keyToGet[keyName] = AttributeValue.S(keyVal)

    val request =
        GetItemRequest {
            key = keyToGet
            tableName = tableNameVal
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        val returnedItem = ddb.getItem(request)
        val numbersMap = returnedItem.item
        numbersMap?.forEach { key1 ->
            println(key1.key)
            println(key1.value)
        }
    }
}
```
+  API-Details finden Sie [GetItem](https://sdk.amazonaws.com/kotlin/api/latest/index.html)in der *API-Referenz zum AWS SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
        $movie = $service->getItemByKey($tableName, $key);
        echo "\nThe movie {$movie['Item']['title']['S']} was released in {$movie['Item']['year']['N']}.\n";

    public function getItemByKey(string $tableName, array $key)
    {
        return $this->dynamoDbClient->getItem([
            'Key' => $key['Item'],
            'TableName' => $tableName,
        ]);
    }
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/GetItem)in der *AWS SDK für PHP API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: Gibt das DynamoDB-Element mit dem Partitionsschlüssel SongTitle und dem Sortierschlüssel Artist zurück.**  

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

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Country
SongTitle                      Somewhere Down The Road
Price                          1.94
Artist                         No One You Know
CriticRating                   9
AlbumTitle                     Somewhat Famous
```
+  Einzelheiten zur API finden Sie unter [GetItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v4/reference)*Cmdlet-Referenz* (V4). 

**Tools für V5 PowerShell **  
**Beispiel 1: Gibt das DynamoDB-Element mit dem Partitionsschlüssel SongTitle und dem Sortierschlüssel Artist zurück.**  

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

Get-DDBItem -TableName 'Music' -Key $key | ConvertFrom-DDBItem
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Country
SongTitle                      Somewhere Down The Road
Price                          1.94
Artist                         No One You Know
CriticRating                   9
AlbumTitle                     Somewhat Famous
```
+  Einzelheiten zur API finden Sie unter [GetItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v5/reference)*Cmdlet-Referenz* (V5). 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def get_movie(self, title, year):
        """
        Gets movie data from the table for a specific movie.

        :param title: The title of the movie.
        :param year: The release year of the movie.
        :return: The data about the requested movie.
        """
        try:
            response = self.table.get_item(Key={"year": year, "title": title})
        except ClientError as err:
            logger.error(
                "Couldn't get movie %s from table %s. Here's why: %s: %s",
                title,
                self.table.name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return response["Item"]
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/GetItem)in *AWS SDK for Python (Boto3) API* Reference. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class DynamoDBBasics
  attr_reader :dynamo_resource, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table = @dynamo_resource.table(table_name)
  end

  # Gets movie data from the table for a specific movie.
  #
  # @param title [String] The title of the movie.
  # @param year [Integer] The release year of the movie.
  # @return [Hash] The data about the requested movie.
  def get_item(title, year)
    @table.get_item(key: { 'year' => year, 'title' => title })
  rescue Aws::DynamoDB::Errors::ServiceError => e
    puts("Couldn't get movie #{title} (#{year}) from table #{@table.name}:\n")
    puts("\t#{e.code}: #{e.message}")
    raise
  end
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/GetItem)in der *AWS SDK für Ruby API-Referenz*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        oo_item = lo_dyn->getitem(
          iv_tablename                = iv_table_name
          it_key                      = it_key ).
        DATA(lt_attr) = oo_item->get_item( ).
        DATA(lo_title) = lt_attr[ key = 'title' ]-value.
        DATA(lo_year) = lt_attr[ key = 'year' ]-value.
        DATA(lo_rating) = lt_attr[ key = 'rating' ]-value.
        MESSAGE 'Movie name is: ' && lo_title->get_s( )
          && 'Movie year is: ' && lo_year->get_n( )
          && 'Moving rating is: ' && lo_rating->get_n( ) TYPE 'I'.
      CATCH /aws1/cx_dynresourcenotfoundex.
        MESSAGE 'The table or index does not exist' TYPE 'E'.
    ENDTRY.
```
+  Einzelheiten zur API finden Sie [GetItem](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    /// Return a `Movie` record describing the specified movie from the Amazon
    /// DynamoDB table.
    ///
    /// - Parameters:
    ///   - title: The movie's title (`String`).
    ///   - year: The movie's release year (`Int`).
    ///
    /// - Throws: `MoviesError.ItemNotFound` if the movie isn't in the table.
    ///
    /// - Returns: A `Movie` record with the movie's details.
    func get(title: String, year: Int) async throws -> Movie {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            let input = GetItemInput(
                key: [
                    "year": .n(String(year)),
                    "title": .s(title)
                ],
                tableName: self.tableName
            )
            let output = try await client.getItem(input: input)
            guard let item = output.item else {
                throw MoviesError.ItemNotFound
            }

            let movie = try Movie(withItem: item)
            return movie
        } catch {
            print("ERROR: get:", dump(error))
            throw error
        }
    }
```
+  Einzelheiten zur API finden Sie [GetItem](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/getitem(input:))in der *API-Referenz zum AWS SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

Um die Daten in Ihrer Tabelle zu aktualisieren, fahren Sie mit [Schritt 4: Aktualisieren von Daten in einer DynamoDB-Tabelle](getting-started-step-4.md) fort.

# Schritt 4: Aktualisieren von Daten in einer DynamoDB-Tabelle
<a name="getting-started-step-4"></a>

In diesem Schritt aktualisieren Sie ein von Ihnen in [Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle](getting-started-step-2.md) erstelltes Element. Sie können die DynamoDB-Konsole oder die verwenden AWS CLI , um ein Element in `AlbumTitle` der `Music` Tabelle zu aktualisieren, indem Sie `Artist``SongTitle`, und das Aktualisierte angeben. `AlbumTitle` 

Weitere Informationen über Schreibvorgänge finden Sie unter [Schreiben eines Elements](WorkingWithItems.md#WorkingWithItems.WritingData).

## AWS-Managementkonsole
<a name="getting-started-step-4-Console"></a>

Sie können mithilfe der DynamoDB-Konsole Daten in der Tabelle `Music` aktualisieren.

1. Öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus.

1. Wählen Sie in der Tabellenliste die Tabelle **Music** (Musik) aus.

1. Wählen Sie **Tabellenelemente erkunden** aus.

1. Gehen Sie **unter Zurückgesendete** Artikel für die Artikelzeile mit **Acme Band** **Artist** und **Happy Day **SongTitle****wie folgt vor:

   1. Platzieren Sie den Mauszeiger auf den **AlbumTitle****Titeln Songs About Life.**

   1. Wählen Sie das Symbol „Bearbeiten“ aus.

   1. Geben Sie im Popup-Fenster **Zeichenfolge bearbeiten** **Songs of Twilight** ein.

   1. Wählen Sie **Speichern**.
**Tipp**  
Um ein Element zu aktualisieren, gehen Sie alternativ im Abschnitt **Zurückgegebene Element** wie folgt vor:  
Wählen Sie die Artikelzeile mit dem **Künstler** namens **Acme Band** und **SongTitle**dem Namen **Happy Day**.
Wählen Sie in der Dropdown-Liste **Aktionen** die Option **Element bearbeiten** aus.
Geben Sie für Enter **AlbumTitle**ein**Songs of Twilight**.
Klicken Sie auf **Save and close**.

## AWS CLI
<a name="getting-started-step-4-CLI"></a>

Im folgenden AWS CLI Beispiel wird ein Element in der `Music` Tabelle aktualisiert. Sie können dies entweder über die DynamoDB-API tun oder [PartiQL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html), eine SQL-kompatible Abfragesprache für DynamoDB.

------
#### [ DynamoDB API ]

**Linux**

```
aws dynamodb update-item \
    --table-name Music \
    --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' \
    --update-expression "SET AlbumTitle = :newval" \
    --expression-attribute-values '{":newval":{"S":"Updated Album Title"}}' \
    --return-values ALL_NEW
```

**Windows CMD**

```
aws dynamodb update-item ^
    --table-name Music ^
    --key "{\"Artist\": {\"S\": \"Acme Band\"}, \"SongTitle\": {\"S\": \"Happy Day\"}}" ^
    --update-expression "SET AlbumTitle = :newval" ^
    --expression-attribute-values "{\":newval\":{\"S\":\"Updated Album Title\"}}" ^
    --return-values ALL_NEW
```

Die Verwendung von `update-item` gibt das folgende Beispielergebnis zurück, da `return-values ALL_NEW` angegeben wurde.

```
{
    "Attributes": {
        "AlbumTitle": {
            "S": "Updated Album Title"
        },
        "Awards": {
            "S": "10"
        },
        "Artist": {
            "S": "Acme Band"
        },
        "SongTitle": {
            "S": "Happy Day"
        }
    }
}
```

------
#### [ PartiQL for DynamoDB ]

**Linux**

```
aws dynamodb execute-statement --statement "UPDATE Music  \
    SET AlbumTitle='Updated Album Title'  \
    WHERE Artist='Acme Band' AND SongTitle='Happy Day' \
    RETURNING ALL NEW *"
```

**Windows CMD**

```
aws dynamodb execute-statement --statement "UPDATE Music SET AlbumTitle='Updated Album Title' WHERE Artist='Acme Band' AND SongTitle='Happy Day' RETURNING ALL NEW *"
```

Die Verwendung der `Update`-Anweisung gibt das folgende Beispielergebnis zurück, da `RETURNING ALL NEW *` angegeben wurde.

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Updated Album Title"
            },
            "Awards": {
                "S": "10"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "Happy Day"
            }
        }
    ]
}
```

Für weitere Informationen zum Aktualisieren von Daten mit PartiQL siehe [PartiQL Update Statements (PartiQL-Update-Anweisungen)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.update.html).

------

## AWS SDK
<a name="getting-started-step-4-SDK"></a>

Die folgenden Codebeispiele zeigen, wie ein Element in einer DynamoDB-Tabelle mithilfe eines AWS SDK aktualisiert wird.

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Updates an existing item in the movies table.
    /// </summary>
    /// <param name="newMovie">A Movie object containing information for
    /// the movie to update.</param>
    /// <param name="newInfo">A MovieInfo object that contains the
    /// information that will be changed.</param>
    /// <param name="tableName">The name of the table that contains the movie.</param>
    /// <returns>A Boolean value that indicates the success of the operation.</returns>
    public async Task<bool> UpdateItemAsync(
        Movie newMovie,
        MovieInfo newInfo,
        string tableName)
    {
        try
        {
            var key = new Dictionary<string, AttributeValue>
            {
                ["title"] = new AttributeValue { S = newMovie.Title },
                ["year"] = new AttributeValue { N = newMovie.Year.ToString() },
            };
            var updates = new Dictionary<string, AttributeValueUpdate>
            {
                ["info.plot"] = new AttributeValueUpdate
                {
                    Action = AttributeAction.PUT,
                    Value = new AttributeValue { S = newInfo.Plot },
                },

                ["info.rating"] = new AttributeValueUpdate
                {
                    Action = AttributeAction.PUT,
                    Value = new AttributeValue { N = newInfo.Rank.ToString() },
                },
            };

            var request = new UpdateItemRequest
            {
                AttributeUpdates = updates,
                Key = key,
                TableName = tableName,
            };

            await _amazonDynamoDB.UpdateItemAsync(request);
            return true;
        }
        catch (ResourceNotFoundException ex)
        {
            Console.WriteLine($"Table {tableName} or item was not found. {ex.Message}");
            return false;
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while updating item. {ex.Message}");
            throw;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while updating item. {ex.Message}");
            throw;
        }
    }
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/UpdateItem)in der *AWS SDK für .NET API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
##############################################################################
# function dynamodb_update_item
#
# This function updates an item in a DynamoDB table.
#
#
# Parameters:
#       -n table_name  -- The name of the table.
#       -k keys  -- Path to json file containing the keys that identify the item to update.
#       -e update expression  -- An expression that defines one or more attributes to be updated.
#       -v values  -- Path to json file containing the update values.
#
#  Returns:
#       0 - If successful.
#       1 - If it fails.
#############################################################################
function dynamodb_update_item() {
  local table_name keys update_expression values response
  local option OPTARG # Required to use getopts command in a function.

  #######################################
  # Function usage explanation
  #######################################
  function usage() {
    echo "function dynamodb_update_item"
    echo "Update an item in a DynamoDB table."
    echo " -n table_name  -- The name of the table."
    echo " -k keys  -- Path to json file containing the keys that identify the item to update."
    echo " -e update expression  -- An expression that defines one or more attributes to be updated."
    echo " -v values  -- Path to json file containing the update values."
    echo ""
  }

  while getopts "n:k:e:v:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      k) keys="${OPTARG}" ;;
      e) update_expression="${OPTARG}" ;;
      v) values="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  if [[ -z "$keys" ]]; then
    errecho "ERROR: You must provide a keys json file path the -k parameter."
    usage
    return 1
  fi
  if [[ -z "$update_expression" ]]; then
    errecho "ERROR: You must provide an update expression with the -e parameter."
    usage
    return 1
  fi

  if [[ -z "$values" ]]; then
    errecho "ERROR: You must provide a values json file path the -v parameter."
    usage
    return 1
  fi

  iecho "Parameters:\n"
  iecho "    table_name:   $table_name"
  iecho "    keys:   $keys"
  iecho "    update_expression:   $update_expression"
  iecho "    values:   $values"

  response=$(aws dynamodb update-item \
    --table-name "$table_name" \
    --key file://"$keys" \
    --update-expression "$update_expression" \
    --expression-attribute-values file://"$values")

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports update-item operation failed.$response"
    return 1
  fi

  return 0

}
```
Die in diesem Beispiel verwendeten Hilfsfunktionen.  

```
###############################################################################
# function iecho
#
# This function enables the script to display the specified text only if
# the global variable $VERBOSE is set to true.
###############################################################################
function iecho() {
  if [[ $VERBOSE == true ]]; then
    echo "$@"
  fi
}

###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/UpdateItem)in der *AWS CLI Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Update an Amazon DynamoDB table item.
/*!
  \sa updateItem()
  \param tableName: The table name.
  \param partitionKey: The partition key.
  \param partitionValue: The value for the partition key.
  \param attributeKey: The key for the attribute to be updated.
  \param attributeValue: The value for the attribute to be updated.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
  */

/*
 *  The example code only sets/updates an attribute value. It processes
 *  the attribute value as a string, even if the value could be interpreted
 *  as a number. Also, the example code does not remove an existing attribute
 *  from the key value.
 */

bool AwsDoc::DynamoDB::updateItem(const Aws::String &tableName,
                                  const Aws::String &partitionKey,
                                  const Aws::String &partitionValue,
                                  const Aws::String &attributeKey,
                                  const Aws::String &attributeValue,
                                  const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);

    // *** Define UpdateItem request arguments.
    // Define TableName argument.
    Aws::DynamoDB::Model::UpdateItemRequest request;
    request.SetTableName(tableName);

    // Define KeyName argument.
    Aws::DynamoDB::Model::AttributeValue attribValue;
    attribValue.SetS(partitionValue);
    request.AddKey(partitionKey, attribValue);

    // Construct the SET update expression argument.
    Aws::String update_expression("SET #a = :valueA");
    request.SetUpdateExpression(update_expression);

    // Construct attribute name argument.
    Aws::Map<Aws::String, Aws::String> expressionAttributeNames;
    expressionAttributeNames["#a"] = attributeKey;
    request.SetExpressionAttributeNames(expressionAttributeNames);

    // Construct attribute value argument.
    Aws::DynamoDB::Model::AttributeValue attributeUpdatedValue;
    attributeUpdatedValue.SetS(attributeValue);
    Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue> expressionAttributeValues;
    expressionAttributeValues[":valueA"] = attributeUpdatedValue;
    request.SetExpressionAttributeValues(expressionAttributeValues);

    // Update the item.
    const Aws::DynamoDB::Model::UpdateItemOutcome &outcome = dynamoClient.UpdateItem(
            request);
    if (outcome.IsSuccess()) {
        std::cout << "Item was updated" << std::endl;
    } else {
        std::cerr << outcome.GetError().GetMessage() << std::endl;
        return false;
    }

    return waitTableActive(tableName, dynamoClient);
}
```
Code, der darauf wartet, dass die Tabelle aktiv wird.  

```
//! Query a newly created DynamoDB table until it is active.
/*!
  \sa waitTableActive()
  \param waitTableActive: The DynamoDB table's name.
  \param dynamoClient: A DynamoDB client.
  \return bool: Function succeeded.
*/
bool AwsDoc::DynamoDB::waitTableActive(const Aws::String &tableName,
                                       const Aws::DynamoDB::DynamoDBClient &dynamoClient) {

    // Repeatedly call DescribeTable until table is ACTIVE.
    const int MAX_QUERIES = 20;
    Aws::DynamoDB::Model::DescribeTableRequest request;
    request.SetTableName(tableName);

    int count = 0;
    while (count < MAX_QUERIES) {
        const Aws::DynamoDB::Model::DescribeTableOutcome &result = dynamoClient.DescribeTable(
                request);
        if (result.IsSuccess()) {
            Aws::DynamoDB::Model::TableStatus status = result.GetResult().GetTable().GetTableStatus();

            if (Aws::DynamoDB::Model::TableStatus::ACTIVE != status) {
                std::this_thread::sleep_for(std::chrono::seconds(1));
            }
            else {
                return true;
            }
        }
        else {
            std::cerr << "Error DynamoDB::waitTableActive "
                      << result.GetError().GetMessage() << std::endl;
            return false;
        }
        count++;
    }
    return false;
}
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/UpdateItem)in der *AWS SDK für C\$1\$1 API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**Beispiel 1: So aktualisieren Sie ein Element in einer Tabelle**  
Im folgenden Beispiel für `update-item` wird ein Element in der Tabelle `MusicCollection` aktualisiert. Es wird ein neues Attribut (`Year`) hinzugefügt und das `AlbumTitle`-Attribut geändert. Alle Attribute im Element, wie sie nach dem Update erscheinen, werden in der Antwort zurückgegeben.  

```
aws dynamodb update-item \
    --table-name MusicCollection \
    --key file://key.json \
    --update-expression "SET #Y = :y, #AT = :t" \
    --expression-attribute-names file://expression-attribute-names.json \
    --expression-attribute-values file://expression-attribute-values.json  \
    --return-values ALL_NEW \
    --return-consumed-capacity TOTAL \
    --return-item-collection-metrics SIZE
```
Inhalt von `key.json`:  

```
{
    "Artist": {"S": "Acme Band"},
    "SongTitle": {"S": "Happy Day"}
}
```
Inhalt von `expression-attribute-names.json`:  

```
{
    "#Y":"Year", "#AT":"AlbumTitle"
}
```
Inhalt von `expression-attribute-values.json`:  

```
{
    ":y":{"N": "2015"},
    ":t":{"S": "Louder Than Ever"}
}
```
Ausgabe:  

```
{
    "Attributes": {
        "AlbumTitle": {
            "S": "Louder Than Ever"
        },
        "Awards": {
            "N": "10"
        },
        "Artist": {
            "S": "Acme Band"
        },
        "Year": {
            "N": "2015"
        },
        "SongTitle": {
            "S": "Happy Day"
        }
    },
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 3.0
    },
    "ItemCollectionMetrics": {
        "ItemCollectionKey": {
            "Artist": {
                "S": "Acme Band"
            }
        },
        "SizeEstimateRangeGB": [
            0.0,
            1.0
        ]
    }
}
```
Weitere Informationen finden Sie unter [Schreiben eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.WritingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 2: So aktualisieren Sie ein Element bedingungsabhängig**  
Im folgenden Beispiel wird ein Element in der `MusicCollection`-Tabelle aktualisiert, jedoch nur, wenn das vorhandene Element noch kein `Year`-Attribut besitzt.  

```
aws dynamodb update-item \
    --table-name MusicCollection \
    --key file://key.json \
    --update-expression "SET #Y = :y, #AT = :t" \
    --expression-attribute-names file://expression-attribute-names.json \
    --expression-attribute-values file://expression-attribute-values.json  \
    --condition-expression "attribute_not_exists(#Y)"
```
Inhalt von `key.json`:  

```
{
    "Artist": {"S": "Acme Band"},
    "SongTitle": {"S": "Happy Day"}
}
```
Inhalt von `expression-attribute-names.json`:  

```
{
    "#Y":"Year",
    "#AT":"AlbumTitle"
}
```
Inhalt von `expression-attribute-values.json`:  

```
{
    ":y":{"N": "2015"},
    ":t":{"S": "Louder Than Ever"}
}
```
Wenn das Element bereits über ein `Year`-Attribut verfügt, gibt DynamoDB die folgende Ausgabe zurück.  

```
An error occurred (ConditionalCheckFailedException) when calling the UpdateItem operation: The conditional request failed
```
Weitere Informationen finden Sie unter [Schreiben eines Elements](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.WritingData) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Einzelheiten zur API finden Sie [UpdateItem](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/update-item.html)in der *AWS CLI Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// UpdateMovie updates the rating and plot of a movie that already exists in the
// DynamoDB table. This function uses the `expression` package to build the update
// expression.
func (basics TableBasics) UpdateMovie(ctx context.Context, movie Movie) (map[string]map[string]interface{}, error) {
	var err error
	var response *dynamodb.UpdateItemOutput
	var attributeMap map[string]map[string]interface{}
	update := expression.Set(expression.Name("info.rating"), expression.Value(movie.Info["rating"]))
	update.Set(expression.Name("info.plot"), expression.Value(movie.Info["plot"]))
	expr, err := expression.NewBuilder().WithUpdate(update).Build()
	if err != nil {
		log.Printf("Couldn't build expression for update. Here's why: %v\n", err)
	} else {
		response, err = basics.DynamoDbClient.UpdateItem(ctx, &dynamodb.UpdateItemInput{
			TableName:                 aws.String(basics.TableName),
			Key:                       movie.GetKey(),
			ExpressionAttributeNames:  expr.Names(),
			ExpressionAttributeValues: expr.Values(),
			UpdateExpression:          expr.Update(),
			ReturnValues:              types.ReturnValueUpdatedNew,
		})
		if err != nil {
			log.Printf("Couldn't update movie %v. Here's why: %v\n", movie.Title, err)
		} else {
			err = attributevalue.UnmarshalMap(response.Attributes, &attributeMap)
			if err != nil {
				log.Printf("Couldn't unmarshall update response. Here's why: %v\n", err)
			}
		}
	}
	return attributeMap, err
}
```
Definieren Sie eine Movie-Struktur, die in diesem Beispiel verwendet wird.  

```
import (
	"archive/zip"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// Movie encapsulates data about a movie. Title and Year are the composite primary key
// of the movie in Amazon DynamoDB. Title is the sort key, Year is the partition key,
// and Info is additional data.
type Movie struct {
	Title string                 `dynamodbav:"title"`
	Year  int                    `dynamodbav:"year"`
	Info  map[string]interface{} `dynamodbav:"info"`
}

// GetKey returns the composite primary key of the movie in a format that can be
// sent to DynamoDB.
func (movie Movie) GetKey() map[string]types.AttributeValue {
	title, err := attributevalue.Marshal(movie.Title)
	if err != nil {
		panic(err)
	}
	year, err := attributevalue.Marshal(movie.Year)
	if err != nil {
		panic(err)
	}
	return map[string]types.AttributeValue{"title": title, "year": year}
}

// String returns the title, year, rating, and plot of a movie, formatted for the example.
func (movie Movie) String() string {
	return fmt.Sprintf("%v\n\tReleased: %v\n\tRating: %v\n\tPlot: %v\n",
		movie.Title, movie.Year, movie.Info["rating"], movie.Info["plot"])
}
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.UpdateItem)in der *AWS SDK für Go API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 
Aktualisiert ein Element in einer Tabelle mit [DynamoDbClient](https://docs.aws.amazon.com/sdk-for-java/latest/reference/software/amazon/awssdk/services/dynamodb/DynamoDbClient.html).  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.AttributeAction;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate;
import software.amazon.awssdk.services.dynamodb.model.UpdateItemRequest;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import java.util.HashMap;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 *
 * To update an Amazon DynamoDB table using the AWS SDK for Java V2, its better
 * practice to use the
 * Enhanced Client, See the EnhancedModifyItem example.
 */
public class UpdateItem {
    public static void main(String[] args) {
        final String usage = """

                Usage:
                    <tableName> <key> <keyVal> <name> <updateVal>

                Where:
                    tableName - The Amazon DynamoDB table (for example, Music3).
                    key - The name of the key in the table (for example, Artist).
                    keyVal - The value of the key (for example, Famous Band).
                    name - The name of the column where the value is updated (for example, Awards).
                    updateVal - The value used to update an item (for example, 14).
                 Example:
                    UpdateItem Music3 Artist Famous Band Awards 14
                """;

        if (args.length != 5) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        String key = args[1];
        String keyVal = args[2];
        String name = args[3];
        String updateVal = args[4];

        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();
        updateTableItem(ddb, tableName, key, keyVal, name, updateVal);
        ddb.close();
    }

    public static void updateTableItem(DynamoDbClient ddb,
            String tableName,
            String key,
            String keyVal,
            String name,
            String updateVal) {

        HashMap<String, AttributeValue> itemKey = new HashMap<>();
        itemKey.put(key, AttributeValue.builder()
                .s(keyVal)
                .build());

        HashMap<String, AttributeValueUpdate> updatedValues = new HashMap<>();
        updatedValues.put(name, AttributeValueUpdate.builder()
                .value(AttributeValue.builder().s(updateVal).build())
                .action(AttributeAction.PUT)
                .build());

        UpdateItemRequest request = UpdateItemRequest.builder()
                .tableName(tableName)
                .key(itemKey)
                .attributeUpdates(updatedValues)
                .build();

        try {
            ddb.updateItem(request);
        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("The Amazon DynamoDB table was updated!");
    }
}
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/UpdateItem)unter *AWS SDK for Java 2.x API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 
In diesem Beispiel wird der Dokument-Client verwendet, um die Arbeit mit Elementen in DynamoDB zu vereinfachen. Einzelheiten zur API finden Sie unter [UpdateCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/Class/UpdateCommand/).  

```
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, UpdateCommand } from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

export const main = async () => {
  const command = new UpdateCommand({
    TableName: "Dogs",
    Key: {
      Breed: "Labrador",
    },
    UpdateExpression: "set Color = :color",
    ExpressionAttributeValues: {
      ":color": "black",
    },
    ReturnValues: "ALL_NEW",
  });

  const response = await docClient.send(command);
  console.log(response);
  return response;
};
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/UpdateItemCommand)unter *AWS SDK für JavaScript API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun updateTableItem(
    tableNameVal: String,
    keyName: String,
    keyVal: String,
    name: String,
    updateVal: String,
) {
    val itemKey = mutableMapOf<String, AttributeValue>()
    itemKey[keyName] = AttributeValue.S(keyVal)

    val updatedValues = mutableMapOf<String, AttributeValueUpdate>()
    updatedValues[name] =
        AttributeValueUpdate {
            value = AttributeValue.S(updateVal)
            action = AttributeAction.Put
        }

    val request =
        UpdateItemRequest {
            tableName = tableNameVal
            key = itemKey
            attributeUpdates = updatedValues
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        ddb.updateItem(request)
        println("Item in $tableNameVal was updated")
    }
}
```
+  API-Details finden Sie [UpdateItem](https://sdk.amazonaws.com/kotlin/api/latest/index.html)in der *API-Referenz zum AWS SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
        echo "What rating would you like to give {$movie['Item']['title']['S']}?\n";
        $rating = 0;
        while (!is_numeric($rating) || intval($rating) != $rating || $rating < 1 || $rating > 10) {
            $rating = testable_readline("Rating (1-10): ");
        }
        $service->updateItemAttributeByKey($tableName, $key, 'rating', 'N', $rating);

    public function updateItemAttributeByKey(
        string $tableName,
        array $key,
        string $attributeName,
        string $attributeType,
        string $newValue
    ) {
        $this->dynamoDbClient->updateItem([
            'Key' => $key['Item'],
            'TableName' => $tableName,
            'UpdateExpression' => "set #NV=:NV",
            'ExpressionAttributeNames' => [
                '#NV' => $attributeName,
            ],
            'ExpressionAttributeValues' => [
                ':NV' => [
                    $attributeType => $newValue
                ]
            ],
        ]);
    }
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/UpdateItem)in der *AWS SDK für PHP API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: Setzt das Genre-Attribut auf 'Rap' für das DynamoDB-Element mit dem Partitionsschlüssel SongTitle und dem Sortierschlüssel Artist.**  

```
$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
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Rap
```
+  Einzelheiten zur API finden Sie unter [UpdateItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v4/reference)*Cmdlet-Referenz* (V4). 

**Tools für V5 PowerShell **  
**Beispiel 1: Setzt das Genre-Attribut auf 'Rap' für das DynamoDB-Element mit dem Partitionsschlüssel SongTitle und dem Sortierschlüssel Artist.**  

```
$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
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Rap
```
+  Einzelheiten zur API finden Sie unter [UpdateItem AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v5/reference)*Cmdlet-Referenz* (V5). 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 
Aktualisieren Sie ein Element mithilfe eines Aktualisierungsausdrucks.  

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def update_movie(self, title, year, rating, plot):
        """
        Updates rating and plot data for a movie in the table.

        :param title: The title of the movie to update.
        :param year: The release year of the movie to update.
        :param rating: The updated rating to the give the movie.
        :param plot: The updated plot summary to give the movie.
        :return: The fields that were updated, with their new values.
        """
        try:
            response = self.table.update_item(
                Key={"year": year, "title": title},
                UpdateExpression="set info.rating=:r, info.plot=:p",
                ExpressionAttributeValues={":r": Decimal(str(rating)), ":p": plot},
                ReturnValues="UPDATED_NEW",
            )
        except ClientError as err:
            logger.error(
                "Couldn't update movie %s in table %s. Here's why: %s: %s",
                title,
                self.table.name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return response["Attributes"]
```
Aktualisieren Sie ein Element mithilfe eines Aktualisierungsausdrucks, der eine arithmetische Operation enthält.  

```
class UpdateQueryWrapper:
    def __init__(self, table):
        self.table = table


    def update_rating(self, title, year, rating_change):
        """
        Updates the quality rating of a movie in the table by using an arithmetic
        operation in the update expression. By specifying an arithmetic operation,
        you can adjust a value in a single request, rather than first getting its
        value and then setting its new value.

        :param title: The title of the movie to update.
        :param year: The release year of the movie to update.
        :param rating_change: The amount to add to the current rating for the movie.
        :return: The updated rating.
        """
        try:
            response = self.table.update_item(
                Key={"year": year, "title": title},
                UpdateExpression="set info.rating = info.rating + :val",
                ExpressionAttributeValues={":val": Decimal(str(rating_change))},
                ReturnValues="UPDATED_NEW",
            )
        except ClientError as err:
            logger.error(
                "Couldn't update movie %s in table %s. Here's why: %s: %s",
                title,
                self.table.name,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return response["Attributes"]
```
Aktualisieren Sie ein Element nur, wenn es bestimmte Bedingungen erfüllt.  

```
class UpdateQueryWrapper:
    def __init__(self, table):
        self.table = table


    def remove_actors(self, title, year, actor_threshold):
        """
        Removes an actor from a movie, but only when the number of actors is greater
        than a specified threshold. If the movie does not list more than the threshold,
        no actors are removed.

        :param title: The title of the movie to update.
        :param year: The release year of the movie to update.
        :param actor_threshold: The threshold of actors to check.
        :return: The movie data after the update.
        """
        try:
            response = self.table.update_item(
                Key={"year": year, "title": title},
                UpdateExpression="remove info.actors[0]",
                ConditionExpression="size(info.actors) > :num",
                ExpressionAttributeValues={":num": actor_threshold},
                ReturnValues="ALL_NEW",
            )
        except ClientError as err:
            if err.response["Error"]["Code"] == "ConditionalCheckFailedException":
                logger.warning(
                    "Didn't update %s because it has fewer than %s actors.",
                    title,
                    actor_threshold + 1,
                )
            else:
                logger.error(
                    "Couldn't update movie %s. Here's why: %s: %s",
                    title,
                    err.response["Error"]["Code"],
                    err.response["Error"]["Message"],
                )
            raise
        else:
            return response["Attributes"]
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/UpdateItem)in *AWS SDK for Python (Boto3) API* Reference. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class DynamoDBBasics
  attr_reader :dynamo_resource, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table = @dynamo_resource.table(table_name)
  end

  # Updates rating and plot data for a movie in the table.
  #
  # @param movie [Hash] The title, year, plot, rating of the movie.
  def update_item(movie)
    response = @table.update_item(
      key: { 'year' => movie[:year], 'title' => movie[:title] },
      update_expression: 'set info.rating=:r',
      expression_attribute_values: { ':r' => movie[:rating] },
      return_values: 'UPDATED_NEW'
    )
  rescue Aws::DynamoDB::Errors::ServiceError => e
    puts("Couldn't update movie #{movie[:title]} (#{movie[:year]}) in table #{@table.name}\n")
    puts("\t#{e.code}: #{e.message}")
    raise
  else
    response.attributes
  end
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/UpdateItem)in der *AWS SDK für Ruby API-Referenz*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        oo_output = lo_dyn->updateitem(
          iv_tablename        = iv_table_name
          it_key              = it_item_key
          it_attributeupdates = it_attribute_updates ).
        MESSAGE '1 item updated in DynamoDB Table' && iv_table_name TYPE 'I'.
      CATCH /aws1/cx_dyncondalcheckfaile00.
        MESSAGE 'A condition specified in the operation could not be evaluated.' TYPE 'E'.
      CATCH /aws1/cx_dynresourcenotfoundex.
        MESSAGE 'The table or index does not exist' TYPE 'E'.
      CATCH /aws1/cx_dyntransactconflictex.
        MESSAGE 'Another transaction is using the item' TYPE 'E'.
    ENDTRY.
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    /// Update the specified movie with new `rating` and `plot` information.
    ///
    /// - Parameters:
    ///   - title: The title of the movie to update.
    ///   - year: The release year of the movie to update.
    ///   - rating: The new rating for the movie.
    ///   - plot: The new plot summary string for the movie.
    ///
    /// - Returns: An array of mappings of attribute names to their new
    ///   listing each item actually changed. Items that didn't need to change
    ///   aren't included in this list. `nil` if no changes were made.
    ///
    func update(title: String, year: Int, rating: Double? = nil, plot: String? = nil) async throws
        -> [Swift.String: DynamoDBClientTypes.AttributeValue]?
    {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            // Build the update expression and the list of expression attribute
            // values. Include only the information that's changed.

            var expressionParts: [String] = []
            var attrValues: [Swift.String: DynamoDBClientTypes.AttributeValue] = [:]

            if rating != nil {
                expressionParts.append("info.rating=:r")
                attrValues[":r"] = .n(String(rating!))
            }
            if plot != nil {
                expressionParts.append("info.plot=:p")
                attrValues[":p"] = .s(plot!)
            }
            let expression = "set \(expressionParts.joined(separator: ", "))"

            let input = UpdateItemInput(
                // Create substitution tokens for the attribute values, to ensure
                // no conflicts in expression syntax.
                expressionAttributeValues: attrValues,
                // The key identifying the movie to update consists of the release
                // year and title.
                key: [
                    "year": .n(String(year)),
                    "title": .s(title)
                ],
                returnValues: .updatedNew,
                tableName: self.tableName,
                updateExpression: expression
            )
            let output = try await client.updateItem(input: input)

            guard let attributes: [Swift.String: DynamoDBClientTypes.AttributeValue] = output.attributes else {
                throw MoviesError.InvalidAttributes
            }
            return attributes
        } catch {
            print("ERROR: update:", dump(error))
            throw error
        }
    }
```
+  Einzelheiten zur API finden Sie [UpdateItem](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/updateitem(input:))in der *API-Referenz zum AWS SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

Um die Daten in der Tabelle `Music` abzufragen, fahren Sie mit [Schritt 5: Abfragen der Daten in der DynamoDB-Tabelle](getting-started-step-5.md) fort.

# Schritt 5: Abfragen der Daten in der DynamoDB-Tabelle
<a name="getting-started-step-5"></a>

In diesem Schritt fragen Sie durch Angabe von `Artist` die Daten ab, die Sie in [Schritt 2: Schreiben von Daten in eine DynamoDB-Tabelle](getting-started-step-2.md) in die Tabelle `Music` geschrieben haben. Dadurch werden alle Lieder angezeigt, die mit dem Partitionsschlüssel verknüpft sind: `Artist`.

Weitere Informationen über Abfrageoperationen finden Sie unter [Abfragen von Tabellen in DynamoDB](Query.md). 

## AWS-Managementkonsole
<a name="getting-started-step-5-Console"></a>

Gehen Sie wie folgt vor, um mithilfe der DynamoDB-Konsole Daten in der Tabelle `Music` abzufragen.

1. Öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus.

1. Wählen Sie in der Tabellenliste die Tabelle **Music** (Musik) aus.

1. Wählen Sie **Tabellenelemente erkunden** aus.

1. Stellen Sie sicher, dass unter **Elemente scannen oder abfragen** die Option **Abfrage** ausgewählt ist.

1. Geben Sie für **Partition key** (Partitionsschlüssel) **Acme Band** ein und wählen Sie dann **Run** (Ausführen).

## AWS CLI
<a name="getting-started-step-5-CLI"></a>

Im folgenden AWS CLI Beispiel wird ein Element in der `Music` Tabelle abgefragt. Sie können dies entweder über die DynamoDB-API tun oder [PartiQL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html), eine SQL-kompatible Abfragesprache für DynamoDB.

------
#### [ DynamoDB API ]

Sie fragen ein Element über die DynamoDB-API ab, indem Sie `query` verwenden und den Partitionsschlüssel bereitstellen.

**Linux**

```
aws dynamodb query \
    --table-name Music \
    --key-condition-expression "Artist = :name" \
    --expression-attribute-values  '{":name":{"S":"Acme Band"}}'
```

**Windows CMD**

```
aws dynamodb query ^
    --table-name Music ^
    --key-condition-expression "Artist = :name" ^
    --expression-attribute-values  "{\":name\":{\"S\":\"Acme Band\"}}"
```

Verwendung von `query` gibt alle Songs zurück, die mit diesem bestimmten `Artist` assoziiert sind.

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Updated Album Title"
            },
            "Awards": {
                "N": "10"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "Happy Day"
            }
        },
        {
            "AlbumTitle": {
                "S": "Another Album Title"
            },
            "Awards": {
                "N": "8"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "PartiQL Rocks"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": null
}
```

------
#### [ PartiQL for DynamoDB ]

Sie fragen ein Element über PartiQL ab, indem Sie die `Select`-Anweisung verwenden und den Partitionsschlüssel bereitstellen.

**Linux**

```
aws dynamodb execute-statement --statement "SELECT * FROM Music   \
                                            WHERE Artist='Acme Band'"
```

**Windows CMD**

```
aws dynamodb execute-statement --statement "SELECT * FROM Music WHERE Artist='Acme Band'"
```

Verwendung der `Select`-Anweisung gibt auf diese Weise alle Songs zurück, die mit diesem bestimmten `Artist` assoziiert sind.

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Updated Album Title"
            },
            "Awards": {
                "S": "10"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "Happy Day"
            }
        },
        {
            "AlbumTitle": {
                "S": "Another Album Title"
            },
            "Awards": {
                "S": "8"
            },
            "Artist": {
                "S": "Acme Band"
            },
            "SongTitle": {
                "S": "PartiQL Rocks"
            }
        }
    ]
}
```

Für weitere Informationen zum Abfragen von Daten mit PartiQL siehe [PartiQL Select Statements (PartiQL-Select-Anweisungen)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.select.html).

------

## AWS SDK
<a name="getting-started-step-5-SDK"></a>

In den folgenden Codebeispielen wird gezeigt, wie eine DynamoDB-Tabelle mit einem AWS -SDK abgefragt wird.

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Queries the table for movies released in a particular year and
    /// then displays the information for the movies returned.
    /// </summary>
    /// <param name="tableName">The name of the table to query.</param>
    /// <param name="year">The release year for which we want to
    /// view movies.</param>
    /// <returns>The number of movies that match the query.</returns>
    public async Task<int> QueryMoviesAsync(string tableName, int year)
    {
        try
        {
            var movieTable = new TableBuilder(_amazonDynamoDB, tableName)
                .AddHashKey("year", DynamoDBEntryType.Numeric)
                .AddRangeKey("title", DynamoDBEntryType.String)
                .Build();

            var filter = new QueryFilter("year", QueryOperator.Equal, year);

            Console.WriteLine("\nFind movies released in: {year}:");

            var config = new QueryOperationConfig()
            {
                Limit = 10, // 10 items per page.
                Select = SelectValues.SpecificAttributes,
                AttributesToGet = new List<string>
                {
                    "title",
                    "year",
                },
                ConsistentRead = true,
                Filter = filter,
            };

            // Value used to track how many movies match the
            // supplied criteria.
            var moviesFound = 0;

            var search = movieTable.Query(config);
            do
            {
                var movieList = await search.GetNextSetAsync();
                moviesFound += movieList.Count;

                foreach (var movie in movieList)
                {
                    DisplayDocument(movie);
                }
            }
            while (!search.IsDone);

            return moviesFound;
        }
        catch (ResourceNotFoundException ex)
        {
            Console.WriteLine($"Table {tableName} was not found. {ex.Message}");
            return 0;
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while querying movies. {ex.Message}");
            throw;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while querying movies. {ex.Message}");
            throw;
        }
    }
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/Query) in der *AWS SDK für .NET -API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
#############################################################################
# function dynamodb_query
#
# This function queries a DynamoDB table.
#
# Parameters:
#       -n table_name  -- The name of the table.
#       -k key_condition_expression -- The key condition expression.
#       -a attribute_names -- Path to JSON file containing the attribute names.
#       -v attribute_values -- Path to JSON file containing the attribute values.
#       [-p projection_expression]  -- Optional projection expression.
#
#  Returns:
#       The items as json output.
#  And:
#       0 - If successful.
#       1 - If it fails.
###########################################################################
function dynamodb_query() {
  local table_name key_condition_expression attribute_names attribute_values projection_expression response
  local option OPTARG # Required to use getopts command in a function.

  # ######################################
  # Function usage explanation
  #######################################
  function usage() {
    echo "function dynamodb_query"
    echo "Query a DynamoDB table."
    echo " -n table_name  -- The name of the table."
    echo " -k key_condition_expression -- The key condition expression."
    echo " -a attribute_names -- Path to JSON file containing the attribute names."
    echo " -v attribute_values -- Path to JSON file containing the attribute values."
    echo " [-p projection_expression]  -- Optional projection expression."
    echo ""
  }

  while getopts "n:k:a:v:p:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      k) key_condition_expression="${OPTARG}" ;;
      a) attribute_names="${OPTARG}" ;;
      v) attribute_values="${OPTARG}" ;;
      p) projection_expression="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  if [[ -z "$key_condition_expression" ]]; then
    errecho "ERROR: You must provide a key condition expression with the -k parameter."
    usage
    return 1
  fi

  if [[ -z "$attribute_names" ]]; then
    errecho "ERROR: You must provide a attribute names with the -a parameter."
    usage
    return 1
  fi

  if [[ -z "$attribute_values" ]]; then
    errecho "ERROR: You must provide a attribute values with the -v parameter."
    usage
    return 1
  fi

  if [[ -z "$projection_expression" ]]; then
    response=$(aws dynamodb query \
      --table-name "$table_name" \
      --key-condition-expression "$key_condition_expression" \
      --expression-attribute-names file://"$attribute_names" \
      --expression-attribute-values file://"$attribute_values")
  else
    response=$(aws dynamodb query \
      --table-name "$table_name" \
      --key-condition-expression "$key_condition_expression" \
      --expression-attribute-names file://"$attribute_names" \
      --expression-attribute-values file://"$attribute_values" \
      --projection-expression "$projection_expression")
  fi

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports query operation failed.$response"
    return 1
  fi

  echo "$response"

  return 0
}
```
Die in diesem Beispiel verwendeten Dienstprogrammfunktionen.  

```
###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/Query) in der *AWS CLI -Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Perform a query on an Amazon DynamoDB Table and retrieve items.
/*!
  \sa queryItem()
  \param tableName: The table name.
  \param partitionKey: The partition key.
  \param partitionValue: The value for the partition key.
  \param projectionExpression: The projections expression, which is ignored if empty.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
  */

/*
 * The partition key attribute is searched with the specified value. By default, all fields and values
 * contained in the item are returned. If an optional projection expression is
 * specified on the command line, only the specified fields and values are
 * returned.
 */

bool AwsDoc::DynamoDB::queryItems(const Aws::String &tableName,
                                  const Aws::String &partitionKey,
                                  const Aws::String &partitionValue,
                                  const Aws::String &projectionExpression,
                                  const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);
    Aws::DynamoDB::Model::QueryRequest request;

    request.SetTableName(tableName);

    if (!projectionExpression.empty()) {
        request.SetProjectionExpression(projectionExpression);
    }

    // Set query key condition expression.
    request.SetKeyConditionExpression(partitionKey + "= :valueToMatch");

    // Set Expression AttributeValues.
    Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue> attributeValues;
    attributeValues.emplace(":valueToMatch", partitionValue);

    request.SetExpressionAttributeValues(attributeValues);

    bool result = true;

    // "exclusiveStartKey" is used for pagination.
    Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue> exclusiveStartKey;
    do {
        if (!exclusiveStartKey.empty()) {
            request.SetExclusiveStartKey(exclusiveStartKey);
            exclusiveStartKey.clear();
        }
        // Perform Query operation.
        const Aws::DynamoDB::Model::QueryOutcome &outcome = dynamoClient.Query(request);
        if (outcome.IsSuccess()) {
            // Reference the retrieved items.
            const Aws::Vector<Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue>> &items = outcome.GetResult().GetItems();
            if (!items.empty()) {
                std::cout << "Number of items retrieved from Query: " << items.size()
                          << std::endl;
                // Iterate each item and print.
                for (const auto &item: items) {
                    std::cout
                            << "******************************************************"
                            << std::endl;
                    // Output each retrieved field and its value.
                    for (const auto &i: item)
                        std::cout << i.first << ": " << i.second.GetS() << std::endl;
                }
            }
            else {
                std::cout << "No item found in table: " << tableName << std::endl;
            }

            exclusiveStartKey = outcome.GetResult().GetLastEvaluatedKey();
        }
        else {
            std::cerr << "Failed to Query items: " << outcome.GetError().GetMessage();
            result = false;
            break;
        }
    } while (!exclusiveStartKey.empty());

    return result;
}
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/Query) in der *AWS SDK für C\$1\$1 -API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**Beispiel 1: So fragen Sie eine Tabelle ab**  
Im folgenden Beispiel für `query` werden Elemente in der Tabelle `MusicCollection` abgefragt. Die Tabelle hat einen hash-and-range Primärschlüssel (`Artist`und`SongTitle`), aber diese Abfrage spezifiziert nur den Hashschlüsselwert. Es werden Songtitel des Künstlers mit dem Namen „No One You Know“ zurückgegeben.  

```
aws dynamodb query \
    --table-name MusicCollection \
    --projection-expression "SongTitle" \
    --key-condition-expression "Artist = :v1" \
    --expression-attribute-values file://expression-attributes.json \
    --return-consumed-capacity TOTAL
```
Inhalt von `expression-attributes.json`:  

```
{
    ":v1": {"S": "No One You Know"}
}
```
Ausgabe:  

```
{
    "Items": [
        {
            "SongTitle": {
                "S": "Call Me Today"
            },
            "SongTitle": {
                "S": "Scared of My Shadow"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 0.5
    }
}
```
Weitere Informationen finden Sie unter [Arbeiten mit Abfragen in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 2: So fragen Sie eine Tabelle mit strikt konsistenten Lesevorgängen ab und durchlaufen den Index in absteigender Reihenfolge**  
Im folgenden Beispiel wird dieselbe Abfrage wie im ersten Beispiel ausgeführt, die Ergebnisse werden jedoch in umgekehrter Reihenfolge zurückgegeben und es werden strikt konsistente Lesevorgänge verwendet.  

```
aws dynamodb query \
    --table-name MusicCollection \
    --projection-expression "SongTitle" \
    --key-condition-expression "Artist = :v1" \
    --expression-attribute-values file://expression-attributes.json \
    --consistent-read \
    --no-scan-index-forward \
    --return-consumed-capacity TOTAL
```
Inhalt von `expression-attributes.json`:  

```
{
    ":v1": {"S": "No One You Know"}
}
```
Ausgabe:  

```
{
    "Items": [
        {
            "SongTitle": {
                "S": "Scared of My Shadow"
            }
        },
        {
            "SongTitle": {
                "S": "Call Me Today"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 1.0
    }
}
```
Weitere Informationen finden Sie unter [Arbeiten mit Abfragen in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 3: So filtern Sie bestimmte Ergebnisse heraus**  
Im folgende Beispiel wird `MusicCollection` abgefragt, Ergebnisse mit bestimmten Werten im `AlbumTitle`-Attribut werden jedoch ausgeschlossen. Beachten Sie, dass sich dies nicht auf `ScannedCount` oder `ConsumedCapacity` auswirkt, da der Filter angewendet wird, nachdem die Elemente gelesen wurden.  

```
aws dynamodb query \
    --table-name MusicCollection \
    --key-condition-expression "#n1 = :v1" \
    --filter-expression "NOT (#n2 IN (:v2, :v3))" \
    --expression-attribute-names file://names.json \
    --expression-attribute-values file://values.json \
    --return-consumed-capacity TOTAL
```
Inhalt von `values.json`:  

```
{
    ":v1": {"S": "No One You Know"},
    ":v2": {"S": "Blue Sky Blues"},
    ":v3": {"S": "Greatest Hits"}
}
```
Inhalt von `names.json`:  

```
{
    "#n1": "Artist",
    "#n2": "AlbumTitle"
}
```
Ausgabe:  

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Somewhat Famous"
            },
            "Artist": {
                "S": "No One You Know"
            },
            "SongTitle": {
                "S": "Call Me Today"
            }
        }
    ],
    "Count": 1,
    "ScannedCount": 2,
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 0.5
    }
}
```
Weitere Informationen finden Sie unter [Arbeiten mit Abfragen in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 4: So rufen Sie nur die Elementanzahl ab**  
Das folgende Beispiel ruft eine Anzahl von Elementen ab, die der Abfrage entsprechen, ruft jedoch keines der Elemente selbst ab.  

```
aws dynamodb query \
    --table-name MusicCollection \
    --select COUNT \
    --key-condition-expression "Artist = :v1" \
    --expression-attribute-values file://expression-attributes.json
```
Inhalt von `expression-attributes.json`:  

```
{
    ":v1": {"S": "No One You Know"}
}
```
Ausgabe:  

```
{
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": null
}
```
Weitere Informationen finden Sie unter [Arbeiten mit Abfragen in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
**Beispiel 5: So rufen Sie einen Index ab**  
Im folgenden Beispiel wird der lokale sekundäre Index `AlbumTitleIndex` abgefragt. Die Abfrage gibt alle Attribute aus der Basistabelle zurück, die in den lokalen sekundären Index projiziert wurden. Beachten Sie, dass Sie bei der Abfrage eines lokalen sekundären Index oder eines globalen sekundären Index auch den Namen der Basistabelle mit dem `table-name`-Parameter angeben müssen.  

```
aws dynamodb query \
    --table-name MusicCollection \
    --index-name AlbumTitleIndex \
    --key-condition-expression "Artist = :v1" \
    --expression-attribute-values file://expression-attributes.json \
    --select ALL_PROJECTED_ATTRIBUTES \
    --return-consumed-capacity INDEXES
```
Inhalt von `expression-attributes.json`:  

```
{
    ":v1": {"S": "No One You Know"}
}
```
Ausgabe:  

```
{
    "Items": [
        {
            "AlbumTitle": {
                "S": "Blue Sky Blues"
            },
            "Artist": {
                "S": "No One You Know"
            },
            "SongTitle": {
                "S": "Scared of My Shadow"
            }
        },
        {
            "AlbumTitle": {
                "S": "Somewhat Famous"
            },
            "Artist": {
                "S": "No One You Know"
            },
            "SongTitle": {
                "S": "Call Me Today"
            }
        }
    ],
    "Count": 2,
    "ScannedCount": 2,
    "ConsumedCapacity": {
        "TableName": "MusicCollection",
        "CapacityUnits": 0.5,
        "Table": {
            "CapacityUnits": 0.0
        },
        "LocalSecondaryIndexes": {
            "AlbumTitleIndex": {
                "CapacityUnits": 0.5
            }
        }
    }
}
```
Weitere Informationen finden Sie unter [Arbeiten mit Abfragen in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Weitere API-Informationen finden Sie unter [Abfragen](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/query.html) in der *AWS CLI -Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// Query gets all movies in the DynamoDB table that were released in the specified year.
// The function uses the `expression` package to build the key condition expression
// that is used in the query.
func (basics TableBasics) Query(ctx context.Context, releaseYear int) ([]Movie, error) {
	var err error
	var response *dynamodb.QueryOutput
	var movies []Movie
	keyEx := expression.Key("year").Equal(expression.Value(releaseYear))
	expr, err := expression.NewBuilder().WithKeyCondition(keyEx).Build()
	if err != nil {
		log.Printf("Couldn't build expression for query. Here's why: %v\n", err)
	} else {
		queryPaginator := dynamodb.NewQueryPaginator(basics.DynamoDbClient, &dynamodb.QueryInput{
			TableName:                 aws.String(basics.TableName),
			ExpressionAttributeNames:  expr.Names(),
			ExpressionAttributeValues: expr.Values(),
			KeyConditionExpression:    expr.KeyCondition(),
		})
		for queryPaginator.HasMorePages() {
			response, err = queryPaginator.NextPage(ctx)
			if err != nil {
				log.Printf("Couldn't query for movies released in %v. Here's why: %v\n", releaseYear, err)
				break
			} else {
				var moviePage []Movie
				err = attributevalue.UnmarshalListOfMaps(response.Items, &moviePage)
				if err != nil {
					log.Printf("Couldn't unmarshal query response. Here's why: %v\n", err)
					break
				} else {
					movies = append(movies, moviePage...)
				}
			}
		}
	}
	return movies, err
}
```
Definieren Sie eine Movie-Struktur, die in diesem Beispiel verwendet wird.  

```
import (
	"archive/zip"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"

	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// Movie encapsulates data about a movie. Title and Year are the composite primary key
// of the movie in Amazon DynamoDB. Title is the sort key, Year is the partition key,
// and Info is additional data.
type Movie struct {
	Title string                 `dynamodbav:"title"`
	Year  int                    `dynamodbav:"year"`
	Info  map[string]interface{} `dynamodbav:"info"`
}

// GetKey returns the composite primary key of the movie in a format that can be
// sent to DynamoDB.
func (movie Movie) GetKey() map[string]types.AttributeValue {
	title, err := attributevalue.Marshal(movie.Title)
	if err != nil {
		panic(err)
	}
	year, err := attributevalue.Marshal(movie.Year)
	if err != nil {
		panic(err)
	}
	return map[string]types.AttributeValue{"title": title, "year": year}
}

// String returns the title, year, rating, and plot of a movie, formatted for the example.
func (movie Movie) String() string {
	return fmt.Sprintf("%v\n\tReleased: %v\n\tRating: %v\n\tPlot: %v\n",
		movie.Title, movie.Year, movie.Info["rating"], movie.Info["plot"])
}
```
+  Weitere API-Informationen finden Sie unter [Query](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.Query) in der *AWS SDK für Go -API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 
Fragt eine Tabelle ab mithilfe von [DynamoDbClient](https://docs.aws.amazon.com/sdk-for-java/latest/reference/software/amazon/awssdk/services/dynamodb/DynamoDbClient.html).  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
import java.util.HashMap;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 *
 * To query items from an Amazon DynamoDB table using the AWS SDK for Java V2,
 * its better practice to use the
 * Enhanced Client. See the EnhancedQueryRecords example.
 */
public class Query {
    public static void main(String[] args) {
        final String usage = """

                Usage:
                    <tableName> <partitionKeyName> <partitionKeyVal>

                Where:
                    tableName - The Amazon DynamoDB table to put the item in (for example, Music3).
                    partitionKeyName - The partition key name of the Amazon DynamoDB table (for example, Artist).
                    partitionKeyVal - The value of the partition key that should match (for example, Famous Band).
                """;

        if (args.length != 3) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        String partitionKeyName = args[1];
        String partitionKeyVal = args[2];

        // For more information about an alias, see:
        // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html
        String partitionAlias = "#a";

        System.out.format("Querying %s", tableName);
        System.out.println("");
        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();

        int count = queryTable(ddb, tableName, partitionKeyName, partitionKeyVal, partitionAlias);
        System.out.println("There were " + count + "  record(s) returned");
        ddb.close();
    }

    public static int queryTable(DynamoDbClient ddb, String tableName, String partitionKeyName, String partitionKeyVal,
            String partitionAlias) {
        // Set up an alias for the partition key name in case it's a reserved word.
        HashMap<String, String> attrNameAlias = new HashMap<String, String>();
        attrNameAlias.put(partitionAlias, partitionKeyName);

        // Set up mapping of the partition name with the value.
        HashMap<String, AttributeValue> attrValues = new HashMap<>();
        attrValues.put(":" + partitionKeyName, AttributeValue.builder()
                .s(partitionKeyVal)
                .build());

        QueryRequest queryReq = QueryRequest.builder()
                .tableName(tableName)
                .keyConditionExpression(partitionAlias + " = :" + partitionKeyName)
                .expressionAttributeNames(attrNameAlias)
                .expressionAttributeValues(attrValues)
                .build();

        try {
            QueryResponse response = ddb.query(queryReq);
            return response.count();

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        return -1;
    }
}
```
Fragt eine Tabelle mithilfe von `DynamoDbClient` und eines sekundären Index ab.  

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.QueryRequest;
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 *
 * Create the Movies table by running the Scenario example and loading the Movie
 * data from the JSON file. Next create a secondary
 * index for the Movies table that uses only the year column. Name the index
 * **year-index**. For more information, see:
 *
 * https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
 */
public class QueryItemsUsingIndex {
    public static void main(String[] args) {
        String tableName = "Movies";
        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();

        queryIndex(ddb, tableName);
        ddb.close();
    }

    public static void queryIndex(DynamoDbClient ddb, String tableName) {
        try {
            Map<String, String> expressionAttributesNames = new HashMap<>();
            expressionAttributesNames.put("#year", "year");
            Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
            expressionAttributeValues.put(":yearValue", AttributeValue.builder().n("2013").build());

            QueryRequest request = QueryRequest.builder()
                    .tableName(tableName)
                    .indexName("year-index")
                    .keyConditionExpression("#year = :yearValue")
                    .expressionAttributeNames(expressionAttributesNames)
                    .expressionAttributeValues(expressionAttributeValues)
                    .build();

            System.out.println("=== Movie Titles ===");
            QueryResponse response = ddb.query(request);
            response.items()
                    .forEach(movie -> System.out.println(movie.get("title").s()));

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
    }
}
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/Query) in der *AWS SDK for Java 2.x -API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 
In diesem Beispiel wird der Dokument-Client verwendet, um die Arbeit mit Elementen in DynamoDB zu vereinfachen. Einzelheiten zur API finden Sie unter [QueryCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/Class/QueryCommand/).  

```
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { QueryCommand, DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

export const main = async () => {
  const command = new QueryCommand({
    TableName: "CoffeeCrop",
    KeyConditionExpression:
      "OriginCountry = :originCountry AND RoastDate > :roastDate",
    ExpressionAttributeValues: {
      ":originCountry": "Ethiopia",
      ":roastDate": "2023-05-01",
    },
    ConsistentRead: true,
  });

  const response = await docClient.send(command);
  console.log(response);
  return response;
};
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-example-query-scan.html#dynamodb-example-table-query-scan-querying). 
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/QueryCommand) in der *AWS SDK für JavaScript -API-Referenz*. 

**SDK für JavaScript (v2)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascript/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create DynamoDB document client
var docClient = new AWS.DynamoDB.DocumentClient({ apiVersion: "2012-08-10" });

var params = {
  ExpressionAttributeValues: {
    ":s": 2,
    ":e": 9,
    ":topic": "PHRASE",
  },
  KeyConditionExpression: "Season = :s and Episode > :e",
  FilterExpression: "contains (Subtitle, :topic)",
  TableName: "EPISODES_TABLE",
};

docClient.query(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data.Items);
  }
});
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-query-scan.html#dynamodb-example-table-query-scan-querying). 
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/Query) in der *AWS SDK für JavaScript -API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun queryDynTable(
    tableNameVal: String,
    partitionKeyName: String,
    partitionKeyVal: String,
    partitionAlias: String,
): Int {
    val attrNameAlias = mutableMapOf<String, String>()
    attrNameAlias[partitionAlias] = partitionKeyName

    // Set up mapping of the partition name with the value.
    val attrValues = mutableMapOf<String, AttributeValue>()
    attrValues[":$partitionKeyName"] = AttributeValue.S(partitionKeyVal)

    val request =
        QueryRequest {
            tableName = tableNameVal
            keyConditionExpression = "$partitionAlias = :$partitionKeyName"
            expressionAttributeNames = attrNameAlias
            this.expressionAttributeValues = attrValues
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        val response = ddb.query(request)
        return response.count
    }
}
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://sdk.amazonaws.com/kotlin/api/latest/index.html) in der *API–Referenz zum AWS  SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
        $birthKey = [
            'Key' => [
                'year' => [
                    'N' => "$birthYear",
                ],
            ],
        ];
        $result = $service->query($tableName, $birthKey);

    public function query(string $tableName, $key)
    {
        $expressionAttributeValues = [];
        $expressionAttributeNames = [];
        $keyConditionExpression = "";
        $index = 1;
        foreach ($key as $name => $value) {
            $keyConditionExpression .= "#" . array_key_first($value) . " = :v$index,";
            $expressionAttributeNames["#" . array_key_first($value)] = array_key_first($value);
            $hold = array_pop($value);
            $expressionAttributeValues[":v$index"] = [
                array_key_first($hold) => array_pop($hold),
            ];
        }
        $keyConditionExpression = substr($keyConditionExpression, 0, -1);
        $query = [
            'ExpressionAttributeValues' => $expressionAttributeValues,
            'ExpressionAttributeNames' => $expressionAttributeNames,
            'KeyConditionExpression' => $keyConditionExpression,
            'TableName' => $tableName,
        ];
        return $this->dynamoDbClient->query($query);
    }
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/Query) in der *AWS SDK für PHP -API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: Ruft eine Abfrage auf, die DynamoDB-Elemente mit dem angegebenen SongTitle Wert und Artist zurückgibt.**  

```
$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
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/powershell/v4/reference) in der *AWS -Tools für PowerShell -Cmdlet-Referenz (V4)*. 

**Tools für V5 PowerShell **  
**Beispiel 1: Ruft eine Abfrage auf, die DynamoDB-Elemente mit dem angegebenen SongTitle Wert und Artist zurückgibt.**  

```
$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
```
**Ausgabe:**  

```
Name                           Value
----                           -----
Genre                          Country
Artist                         No One You Know
Price                          1.94
CriticRating                   9
SongTitle                      Somewhere Down The Road
AlbumTitle                     Somewhat Famous
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/powershell/v5/reference) in der *AWS -Tools für PowerShell -Cmdlet-Referenz (V5)*. 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 
Fragen Sie Elemente mithilfe eines Schlüsselbedingungsausdrucks ab.  

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def query_movies(self, year):
        """
        Queries for movies that were released in the specified year.

        :param year: The year to query.
        :return: The list of movies that were released in the specified year.
        """
        try:
            response = self.table.query(KeyConditionExpression=Key("year").eq(year))
        except ClientError as err:
            logger.error(
                "Couldn't query for movies released in %s. Here's why: %s: %s",
                year,
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
        else:
            return response["Items"]
```
Fragen Sie Elemente ab und projizieren Sie sie, um eine Teilmenge von Daten zurückzugeben.  

```
class UpdateQueryWrapper:
    def __init__(self, table):
        self.table = table


    def query_and_project_movies(self, year, title_bounds):
        """
        Query for movies that were released in a specified year and that have titles
        that start within a range of letters. A projection expression is used
        to return a subset of data for each movie.

        :param year: The release year to query.
        :param title_bounds: The range of starting letters to query.
        :return: The list of movies.
        """
        try:
            response = self.table.query(
                ProjectionExpression="#yr, title, info.genres, info.actors[0]",
                ExpressionAttributeNames={"#yr": "year"},
                KeyConditionExpression=(
                    Key("year").eq(year)
                    & Key("title").between(
                        title_bounds["first"], title_bounds["second"]
                    )
                ),
            )
        except ClientError as err:
            if err.response["Error"]["Code"] == "ValidationException":
                logger.warning(
                    "There's a validation error. Here's the message: %s: %s",
                    err.response["Error"]["Code"],
                    err.response["Error"]["Message"],
                )
            else:
                logger.error(
                    "Couldn't query for movies. Here's why: %s: %s",
                    err.response["Error"]["Code"],
                    err.response["Error"]["Message"],
                )
                raise
        else:
            return response["Items"]
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/Query) in der *API-Referenz zum AWS  SDK für Python (Boto3)*. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class DynamoDBBasics
  attr_reader :dynamo_resource, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table = @dynamo_resource.table(table_name)
  end

  # Queries for movies that were released in the specified year.
  #
  # @param year [Integer] The year to query.
  # @return [Array] The list of movies that were released in the specified year.
  def query_items(year)
    response = @table.query(
      key_condition_expression: '#yr = :year',
      expression_attribute_names: { '#yr' => 'year' },
      expression_attribute_values: { ':year' => year }
    )
  rescue Aws::DynamoDB::Errors::ServiceError => e
    puts("Couldn't query for movies released in #{year}. Here's why:")
    puts("\t#{e.code}: #{e.message}")
    raise
  else
    response.items
  end
```
+  Weitere API-Informationen finden Sie unter [Query](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/Query) in der *AWS SDK für Ruby -API-Referenz*. 

------
#### [ Rust ]

**SDK für Rust**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/dynamodb#code-examples) einrichten und ausführen. 
Finden Sie die Filme, die im angegebenen Jahr gedreht wurden.  

```
pub async fn movies_in_year(
    client: &Client,
    table_name: &str,
    year: u16,
) -> Result<Vec<Movie>, MovieError> {
    let results = client
        .query()
        .table_name(table_name)
        .key_condition_expression("#yr = :yyyy")
        .expression_attribute_names("#yr", "year")
        .expression_attribute_values(":yyyy", AttributeValue::N(year.to_string()))
        .send()
        .await?;

    if let Some(items) = results.items {
        let movies = items.iter().map(|v| v.into()).collect();
        Ok(movies)
    } else {
        Ok(vec![])
    }
}
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.rs/aws-sdk-dynamodb/latest/aws_sdk_dynamodb/client/struct.Client.html#method.query) in der *API-Referenz zum AWS  SDK für Rust*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        " Query movies for a given year .
        DATA(lt_attributelist) = VALUE /aws1/cl_dynattributevalue=>tt_attributevaluelist(
            ( NEW /aws1/cl_dynattributevalue( iv_n = |{ iv_year }| ) ) ).
        DATA(lt_key_conditions) = VALUE /aws1/cl_dyncondition=>tt_keyconditions(
          ( VALUE /aws1/cl_dyncondition=>ts_keyconditions_maprow(
          key = 'year'
          value = NEW /aws1/cl_dyncondition(
          it_attributevaluelist = lt_attributelist
          iv_comparisonoperator = |EQ|
          ) ) ) ).
        oo_result = lo_dyn->query(
          iv_tablename = iv_table_name
          it_keyconditions = lt_key_conditions ).
        DATA(lt_items) = oo_result->get_items( ).
        "You can loop over the results to get item attributes.
        LOOP AT lt_items INTO DATA(lt_item).
          DATA(lo_title) = lt_item[ key = 'title' ]-value.
          DATA(lo_year) = lt_item[ key = 'year' ]-value.
        ENDLOOP.
        DATA(lv_count) = oo_result->get_count( ).
        MESSAGE 'Item count is: ' && lv_count TYPE 'I'.
      CATCH /aws1/cx_dynresourcenotfoundex.
        MESSAGE 'The table or index does not exist' TYPE 'E'.
    ENDTRY.
```
+  Weitere API-Informationen finden Sie unter [Abfragen](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html) in der *API-Referenz für das AWS  SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    /// Get all the movies released in the specified year.
    ///
    /// - Parameter year: The release year of the movies to return.
    ///
    /// - Returns: An array of `Movie` objects describing each matching movie.
    ///
    func getMovies(fromYear year: Int) async throws -> [Movie] {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            let input = QueryInput(
                expressionAttributeNames: [
                    "#y": "year"
                ],
                expressionAttributeValues: [
                    ":y": .n(String(year))
                ],
                keyConditionExpression: "#y = :y",
                tableName: self.tableName
            )
            // Use "Paginated" to get all the movies.
            // This lets the SDK handle the 'lastEvaluatedKey' property in "QueryOutput".

            let pages = client.queryPaginated(input: input)

            var movieList: [Movie] = []
            for try await page in pages {
                guard let items = page.items else {
                    print("Error: no items returned.")
                    continue
                }

                // Convert the found movies into `Movie` objects and return an array
                // of them.

                for item in items {
                    let movie = try Movie(withItem: item)
                    movieList.append(movie)
                }
            }
            return movieList
        } catch {
            print("ERROR: getMovies:", dump(error))
            throw error
        }
    }
```
+  Detaillierte API-Informationen finden Sie unter [Query](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/query(input:)) in der *API-Referenz zum AWS -SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

Um einen globalen sekundären Index für Ihre Tabelle zu erstellen, fahren Sie mit [Schritt 6: (Optional) Löschen der DynamoDB-Tabelle, um Ressourcen zu bereinigen](getting-started-step-6.md) fort.

# Schritt 6: (Optional) Löschen der DynamoDB-Tabelle, um Ressourcen zu bereinigen
<a name="getting-started-step-6"></a>

Wenn Sie die Amazon-DynamoDB-Tabelle, die Sie für das Tutorial verwendet haben, nicht mehr benötigen, können Sie sie löschen. Mit diesem Schritt wird sichergestellt, dass Ihnen keine Ressourcen in Rechnung gestellt werden, die Sie nicht nutzen. Sie können die DynamoDB-Konsole oder die verwenden, AWS CLI um die `Music` Tabelle zu löschen, in der Sie erstellt haben. [Schritt 1: Erstellen einer Tabelle in DynamoDB](getting-started-step-1.md)

Weitere Informationen zu Tabellenoperationen in DynamoDB finden Sie unter [Arbeiten mit Tabellen und Daten in DynamoDB](WorkingWithTables.md). 

## AWS-Managementkonsole
<a name="getting-started-step-8-Console"></a>

So löschen Sie die Tabelle `Music` mithilfe der Konsole:

1. Öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Wählen Sie im linken Navigationsbereich **Tables (Tabellen)** aus.

1. Wählen Sie das Kontrollkästchen neben der Tabelle **Musik** in der Tabellenliste aus.

1. Wählen Sie **Löschen** aus.

## AWS CLI
<a name="getting-started-step-8-CLI"></a>

Das folgende AWS CLI Beispiel löscht die `Music` Tabelle mit. `delete-table`

```
aws dynamodb delete-table --table-name Music
```

## AWS SDK
<a name="getting-started-step-8-SDK"></a>

Mit den folgenden Codebeispielen wird demonstriert, wie Sie ein Element in einer DynamoDB-Tabelle unter Verwendung eines AWS -SDK löschen.

------
#### [ .NET ]

**SDK für .NET (v4)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/DynamoDB#code-examples) einrichten und ausführen. 

```
    /// <summary>
    /// Deletes a DynamoDB table.
    /// </summary>
    /// <param name="tableName">The name of the table to delete.</param>
    /// <returns>A Boolean value indicating the success of the operation.</returns>
    public async Task<bool> DeleteTableAsync(string tableName)
    {
        try
        {
            var request = new DeleteTableRequest
            {
                TableName = tableName,
            };

            var response = await _amazonDynamoDB.DeleteTableAsync(request);

            Console.WriteLine($"Table {response.TableDescription.TableName} successfully deleted.");
            return true;

        }
        catch (ResourceNotFoundException ex)
        {
            Console.WriteLine($"Table {tableName} was not found and cannot be deleted. {ex.Message}");
            return false;
        }
        catch (AmazonDynamoDBException ex)
        {
            Console.WriteLine($"An Amazon DynamoDB error occurred while deleting table {tableName}. {ex.Message}");
            return false;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred while deleting table {tableName}. {ex.Message}");
            return false;
        }
    }
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/DotNetSDKV4/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK für .NET API-Referenz*. 

------
#### [ Bash ]

**AWS CLI mit Bash-Skript**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/aws-cli/bash-linux/dynamodb#code-examples) einrichten und ausführen. 

```
###############################################################################
# function dynamodb_delete_table
#
# This function deletes a DynamoDB table.
#
# Parameters:
#       -n table_name  -- The name of the table to delete.
#
#  Returns:
#       0 - If successful.
#       1 - If it fails.
###############################################################################
function dynamodb_delete_table() {
  local table_name response
  local option OPTARG # Required to use getopts command in a function.

  # bashsupport disable=BP5008
  function usage() {
    echo "function dynamodb_delete_table"
    echo "Deletes an Amazon DynamoDB table."
    echo " -n table_name  -- The name of the table to delete."
    echo ""
  }

  # Retrieve the calling parameters.
  while getopts "n:h" option; do
    case "${option}" in
      n) table_name="${OPTARG}" ;;
      h)
        usage
        return 0
        ;;
      \?)
        echo "Invalid parameter"
        usage
        return 1
        ;;
    esac
  done
  export OPTIND=1

  if [[ -z "$table_name" ]]; then
    errecho "ERROR: You must provide a table name with the -n parameter."
    usage
    return 1
  fi

  iecho "Parameters:\n"
  iecho "    table_name:   $table_name"
  iecho ""

  response=$(aws dynamodb delete-table \
    --table-name "$table_name")

  local error_code=${?}

  if [[ $error_code -ne 0 ]]; then
    aws_cli_error_log $error_code
    errecho "ERROR: AWS reports delete-table operation failed.$response"
    return 1
  fi

  return 0
}
```
Die in diesem Beispiel verwendeten Hilfsfunktionen.  

```
###############################################################################
# function iecho
#
# This function enables the script to display the specified text only if
# the global variable $VERBOSE is set to true.
###############################################################################
function iecho() {
  if [[ $VERBOSE == true ]]; then
    echo "$@"
  fi
}

###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
  printf "%s\n" "$*" 1>&2
}

##############################################################################
# function aws_cli_error_log()
#
# This function is used to log the error messages from the AWS CLI.
#
# See https://docs.aws.amazon.com/cli/latest/topic/return-codes.html#cli-aws-help-return-codes.
#
# The function expects the following argument:
#         $1 - The error code returned by the AWS CLI.
#
#  Returns:
#          0: - Success.
#
##############################################################################
function aws_cli_error_log() {
  local err_code=$1
  errecho "Error code : $err_code"
  if [ "$err_code" == 1 ]; then
    errecho "  One or more S3 transfers failed."
  elif [ "$err_code" == 2 ]; then
    errecho "  Command line failed to parse."
  elif [ "$err_code" == 130 ]; then
    errecho "  Process received SIGINT."
  elif [ "$err_code" == 252 ]; then
    errecho "  Command syntax invalid."
  elif [ "$err_code" == 253 ]; then
    errecho "  The system environment or configuration was invalid."
  elif [ "$err_code" == 254 ]; then
    errecho "  The service returned an error."
  elif [ "$err_code" == 255 ]; then
    errecho "  255 is a catch-all error."
  fi

  return 0
}
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/aws-cli/dynamodb-2012-08-10/DeleteTable)in der *AWS CLI Befehlsreferenz*. 

------
#### [ C\$1\$1 ]

**SDK für C\$1\$1**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
//! Delete an Amazon DynamoDB table.
/*!
  \sa deleteTable()
  \param tableName: The DynamoDB table name.
  \param clientConfiguration: AWS client configuration.
  \return bool: Function succeeded.
*/
bool AwsDoc::DynamoDB::deleteTable(const Aws::String &tableName,
                                   const Aws::Client::ClientConfiguration &clientConfiguration) {
    Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);

    Aws::DynamoDB::Model::DeleteTableRequest request;
    request.SetTableName(tableName);

    const Aws::DynamoDB::Model::DeleteTableOutcome &result = dynamoClient.DeleteTable(
            request);
    if (result.IsSuccess()) {
        std::cout << "Your table \""
                  << result.GetResult().GetTableDescription().GetTableName()
                  << " was deleted.\n";
    }
    else {
        std::cerr << "Failed to delete table: " << result.GetError().GetMessage()
                  << std::endl;
    }

    return result.IsSuccess();
}
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/SdkForCpp/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK für C\$1\$1 API-Referenz*. 

------
#### [ CLI ]

**AWS CLI**  
**So löschen Sie eine Tabelle**  
Im folgenden Beispiel für `delete-table` wird die Tabelle `MusicCollection` gelöscht.  

```
aws dynamodb delete-table \
    --table-name MusicCollection
```
Ausgabe:  

```
{
    "TableDescription": {
        "TableStatus": "DELETING",
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableName": "MusicCollection",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "WriteCapacityUnits": 5,
            "ReadCapacityUnits": 5
        }
    }
}
```
Weitere Informationen finden Sie unter [Löschen einer Tabelle](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html#WorkingWithTables.Basics.DeleteTable) im *Entwicklerhandbuch zu Amazon DynamoDB*.  
+  Einzelheiten zur API finden Sie [DeleteTable](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/delete-table.html)in der *AWS CLI Befehlsreferenz*. 

------
#### [ Go ]

**SDK für Go V2**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2/dynamodb#code-examples) einrichten und ausführen. 

```
import (
	"context"
	"errors"
	"log"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue"
	"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
)

// TableBasics encapsulates the Amazon DynamoDB service actions used in the examples.
// It contains a DynamoDB service client that is used to act on the specified table.
type TableBasics struct {
	DynamoDbClient *dynamodb.Client
	TableName      string
}



// DeleteTable deletes the DynamoDB table and all of its data.
func (basics TableBasics) DeleteTable(ctx context.Context) error {
	_, err := basics.DynamoDbClient.DeleteTable(ctx, &dynamodb.DeleteTableInput{
		TableName: aws.String(basics.TableName)})
	if err != nil {
		log.Printf("Couldn't delete table %v. Here's why: %v\n", basics.TableName, err)
	}
	return err
}
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/dynamodb#Client.DeleteTable)in der *AWS SDK für Go API-Referenz*. 

------
#### [ Java ]

**SDK für Java 2.x**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.DeleteTableRequest;

/**
 * Before running this Java V2 code example, set up your development
 * environment, including your credentials.
 *
 * For more information, see the following documentation topic:
 *
 * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
 */

public class DeleteTable {
    public static void main(String[] args) {
        final String usage = """

                Usage:
                    <tableName>

                Where:
                    tableName - The Amazon DynamoDB table to delete (for example, Music3).

                **Warning** This program will delete the table that you specify!
                """;

        if (args.length != 1) {
            System.out.println(usage);
            System.exit(1);
        }

        String tableName = args[0];
        System.out.format("Deleting the Amazon DynamoDB table %s...\n", tableName);
        Region region = Region.US_EAST_1;
        DynamoDbClient ddb = DynamoDbClient.builder()
                .region(region)
                .build();

        deleteDynamoDBTable(ddb, tableName);
        ddb.close();
    }

    public static void deleteDynamoDBTable(DynamoDbClient ddb, String tableName) {
        DeleteTableRequest request = DeleteTableRequest.builder()
                .tableName(tableName)
                .build();

        try {
            ddb.deleteTable(request);

        } catch (DynamoDbException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println(tableName + " was successfully deleted!");
    }
}
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/SdkForJavaV2/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK for Java 2.x API-Referenz*. 

------
#### [ JavaScript ]

**SDK für JavaScript (v3)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import { DeleteTableCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";

const client = new DynamoDBClient({});

export const main = async () => {
  const command = new DeleteTableCommand({
    TableName: "DecafCoffees",
  });

  const response = await client.send(command);
  console.log(response);
  return response;
};
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/dynamodb/command/DeleteTableCommand)in der *AWS SDK für JavaScript API-Referenz*. 

**SDK für JavaScript (v2)**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascript/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
// Set the region
AWS.config.update({ region: "REGION" });

// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });

var params = {
  TableName: process.argv[2],
};

// Call DynamoDB to delete the specified table
ddb.deleteTable(params, function (err, data) {
  if (err && err.code === "ResourceNotFoundException") {
    console.log("Error: Table not found");
  } else if (err && err.code === "ResourceInUseException") {
    console.log("Error: Table in use");
  } else {
    console.log("Success", data);
  }
});
```
+  Weitere Informationen finden Sie im [AWS SDK für JavaScript -Entwicklerhandbuch](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-examples-using-tables.html#dynamodb-examples-using-tables-deleting-a-table). 
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/AWSJavaScriptSDK/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK für JavaScript API-Referenz*. 

------
#### [ Kotlin ]

**SDK für Kotlin**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb#code-examples) einrichten und ausführen. 

```
suspend fun deleteDynamoDBTable(tableNameVal: String) {
    val request =
        DeleteTableRequest {
            tableName = tableNameVal
        }

    DynamoDbClient.fromEnvironment { region = "us-east-1" }.use { ddb ->
        ddb.deleteTable(request)
        println("$tableNameVal was deleted")
    }
}
```
+  API-Details finden Sie [DeleteTable](https://sdk.amazonaws.com/kotlin/api/latest/index.html)in der *API-Referenz zum AWS SDK für Kotlin*. 

------
#### [ PHP ]

**SDK für PHP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
    public function deleteTable(string $TableName)
    {
        $this->customWaiter(function () use ($TableName) {
            return $this->dynamoDbClient->deleteTable([
                'TableName' => $TableName,
            ]);
        });
    }
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/SdkForPHPV3/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK für PHP API-Referenz*. 

------
#### [ PowerShell ]

**Tools für PowerShell V4**  
**Beispiel 1: Löscht die angegebene Tabelle. Sie werden um eine Bestätigung gebeten, bevor der Vorgang fortgesetzt wird.**  

```
Remove-DDBTable -TableName "myTable"
```
**Beispiel 2: Löscht die angegebene Tabelle. Sie werden nicht zum Bestätigen aufgefordert, bevor der Vorgang fortgesetzt wird.**  

```
Remove-DDBTable -TableName "myTable" -Force
```
+  Einzelheiten zur API finden Sie unter [DeleteTable AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v4/reference)*Cmdlet-Referenz (V4).* 

**Tools für V5 PowerShell **  
**Beispiel 1: Löscht die angegebene Tabelle. Sie werden um eine Bestätigung gebeten, bevor der Vorgang fortgesetzt wird.**  

```
Remove-DDBTable -TableName "myTable"
```
**Beispiel 2: Löscht die angegebene Tabelle. Sie werden nicht zum Bestätigen aufgefordert, bevor der Vorgang fortgesetzt wird.**  

```
Remove-DDBTable -TableName "myTable" -Force
```
+  Einzelheiten zur API finden Sie unter [DeleteTable AWS -Tools für PowerShell](https://docs.aws.amazon.com/powershell/v5/reference)*Cmdlet-Referenz (*V5). 

------
#### [ Python ]

**SDK für Python (Boto3)**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
class Movies:
    """Encapsulates an Amazon DynamoDB table of movie data.

    Example data structure for a movie record in this table:
        {
            "year": 1999,
            "title": "For Love of the Game",
            "info": {
                "directors": ["Sam Raimi"],
                "release_date": "1999-09-15T00:00:00Z",
                "rating": 6.3,
                "plot": "A washed up pitcher flashes through his career.",
                "rank": 4987,
                "running_time_secs": 8220,
                "actors": [
                    "Kevin Costner",
                    "Kelly Preston",
                    "John C. Reilly"
                ]
            }
        }
    """

    def __init__(self, dyn_resource):
        """
        :param dyn_resource: A Boto3 DynamoDB resource.
        """
        self.dyn_resource = dyn_resource
        # The table variable is set during the scenario in the call to
        # 'exists' if the table exists. Otherwise, it is set by 'create_table'.
        self.table = None


    def delete_table(self):
        """
        Deletes the table.
        """
        try:
            self.table.delete()
            self.table = None
        except ClientError as err:
            logger.error(
                "Couldn't delete table. Here's why: %s: %s",
                err.response["Error"]["Code"],
                err.response["Error"]["Message"],
            )
            raise
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/boto3/dynamodb-2012-08-10/DeleteTable)in *AWS SDK for Python (Boto3) API* Reference. 

------
#### [ Ruby ]

**SDK für Ruby**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
# Encapsulates an Amazon DynamoDB table of movie data.
class Scaffold
  attr_reader :dynamo_resource, :table_name, :table

  def initialize(table_name)
    client = Aws::DynamoDB::Client.new(region: 'us-east-1')
    @dynamo_resource = Aws::DynamoDB::Resource.new(client: client)
    @table_name = table_name
    @table = nil
    @logger = Logger.new($stdout)
    @logger.level = Logger::DEBUG
  end

  # Deletes the table.
  def delete_table
    @table.delete
    @table = nil
  rescue Aws::DynamoDB::Errors::ServiceError => e
    puts("Couldn't delete table. Here's why:")
    puts("\t#{e.code}: #{e.message}")
    raise
  end
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/goto/SdkForRubyV3/dynamodb-2012-08-10/DeleteTable)in der *AWS SDK für Ruby API-Referenz*. 

------
#### [ Rust ]

**SDK für Rust**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/dynamodb#code-examples) einrichten und ausführen. 

```
pub async fn delete_table(client: &Client, table: &str) -> Result<DeleteTableOutput, Error> {
    let resp = client.delete_table().table_name(table).send().await;

    match resp {
        Ok(out) => {
            println!("Deleted table");
            Ok(out)
        }
        Err(e) => Err(Error::Unhandled(e.into())),
    }
}
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.rs/aws-sdk-dynamodb/latest/aws_sdk_dynamodb/client/struct.Client.html#method.delete_table)in der *API-Referenz zum AWS SDK für Rust*. 

------
#### [ SAP ABAP ]

**SDK für SAP ABAP**  
 Es gibt noch mehr dazu. GitHub Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap/services/dyn#code-examples) einrichten und ausführen. 

```
    TRY.
        lo_dyn->deletetable( iv_tablename = iv_table_name ).
        " Wait till the table is actually deleted.
        lo_dyn->get_waiter( )->tablenotexists(
          iv_max_wait_time = 200
          iv_tablename     = iv_table_name ).
        MESSAGE 'Table ' && iv_table_name && ' deleted.' TYPE 'I'.
      CATCH /aws1/cx_dynresourcenotfoundex.
        MESSAGE 'The table ' && iv_table_name && ' does not exist' TYPE 'E'.
      CATCH /aws1/cx_dynresourceinuseex.
        MESSAGE 'The table cannot be deleted since it is in use' TYPE 'E'.
    ENDTRY.
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://docs.aws.amazon.com/sdk-for-sap-abap/v1/api/latest/index.html)in der *API-Referenz zum AWS SDK für SAP ABAP*. 

------
#### [ Swift ]

**SDK für Swift**  
 Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das [AWS -Code-Beispiel-](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/dynamodb#code-examples) einrichten und ausführen. 

```
import AWSDynamoDB


    ///
    /// Deletes the table from Amazon DynamoDB.
    ///
    func deleteTable() async throws {
        do {
            guard let client = self.ddbClient else {
                throw MoviesError.UninitializedClient
            }

            let input = DeleteTableInput(
                tableName: self.tableName
            )
            _ = try await client.deleteTable(input: input)
        } catch {
            print("ERROR: deleteTable:", dump(error))
            throw error
        }
    }
```
+  Einzelheiten zur API finden Sie [DeleteTable](https://sdk.amazonaws.com/swift/api/awsdynamodb/latest/documentation/awsdynamodb/dynamodbclient/deletetable(input:))in der *API-Referenz zum AWS SDK für Swift*. 

------

Weitere DynamoDB-Beispiele finden Sie unter [Codebeispiele für DynamoDB mit AWS SDKs](service_code_examples.md).

# Erfahren Sie mehr über DynamoDB
<a name="getting-started-NextSteps"></a>

Weitere Informationen zu Amazon DynamoDB finden Sie in den folgenden Themen:
+ [Arbeiten mit Tabellen und Daten in DynamoDB](WorkingWithTables.md)
+ [Arbeiten mit Elementen und Attributen in DynamoDB](WorkingWithItems.md)
+ [Abfragen von Tabellen in DynamoDB](Query.md)
+ [Verwenden globaler sekundärer Indizes in DynamoDB](GSI.md)
+ [Arbeiten mit TransaktionenBeispiel-Code](transactions.md)
+ [In-Memory-Beschleunigung mit DynamoDB Accelerator (DAX)](DAX.md)
+ [Programmieren mit DynamoDB und AWS SDKs](Programming.md)

# Generieren Sie Infrastrukturcode für Amazon DynamoDB mit Console-to-Code
<a name="console-to-code"></a>

Die Console-to-Code Funktion von Amazon Q Developer vereinfacht das Infrastrukturmanagement für Amazon DynamoDB, indem manuelle Schritte zur Tabellenerstellung in reproduzierbaren Automatisierungscode umgewandelt werden. Diese Funktion hilft Entwicklern, die Konfiguration von Datenbankressourcen in ihren Umgebungen effizient zu skalieren. Weitere Informationen finden Sie unter [Automatisieren AWS-Services mit Amazon Q Developer Console-to-Code](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/console-to-code.html).

Console-to-Code erfasst detaillierte DynamoDB-Tabellenkonfigurationen, einschließlich Partitionsschlüssel, Sortierschlüssel, bereitgestellte Durchsatzeinstellungen und Sekundärindizes, und konvertiert diese in präzise Vorlagen. infrastructure-as-code Mithilfe generativer KI stellt das Tool sicher, dass der generierte Code die während Ihres Konsolen-Workflows festgelegte Parameterkompatibilität beibehält.

Entwickler können DynamoDB-Infrastrukturcode in verschiedenen Formaten generieren, z. B.:
+ AWS Cloud Development Kit (AWS CDK) für Python und Java TypeScript
+ CloudFormation in YAML oder JSON

Dieser Ansatz bietet Teams folgende Möglichkeiten:
+ Standardisieren des Datenbankressourcenmanagements
+ Implementieren einer versionskontrollierten Infrastruktur
+ Reduzieren von manuellen Konfigurationsfehlern

Console-to-Code für Amazon DynamoDB ist in allen AWS Handelsregionen verfügbar und bietet eine leistungsstarke Lösung für die Umwandlung manueller Konfigurationen in automatisierten, reproduzierbaren Infrastrukturcode.

## Funktionsweise
<a name="how-it-works"></a>

Bei der Verwendung Console-to-Code mit DynamoDB umfasst der Prozess in der Regel:

1. **Prototyping in der Konsole**: Verwenden Sie die DynamoDB-Konsole, um Ressourcen wie Tabellen zu erstellen und zu konfigurieren. Unter [Connect to Amazon DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStartedDynamoDB.html) finden Sie weitere Informationen.

1. **Aktionen aufzeichnen** — Console-to-Code zeichnet diese Aktionen auf, während Sie sie ausführen.

1. **Codegenerierung**: Die Funktion nutzt die generativen KI-Funktionen von Amazon Q Developer, um Ihre Konsolenaktionen in wiederverwendbaren Code in Ihrem bevorzugten Format umzuwandeln.

1. **Code-Anpassung**: Sie können diesen Code dann kopieren oder herunterladen und ihn weiter an Ihre Produktions-Workloads anpassen.

## Vorteile der Verwendung Console-to-Code mit DynamoDB
<a name="benefits"></a>

**Vereinfachte Automatisierung**  
Konvertieren Sie die manuelle Erstellung und Konfiguration von DynamoDB-Tabellen mit einem einzigen Klick in wiederverwendbaren Code.

**Best Practices**  
Der generierte Code folgt AWS bewährten Methoden für zuverlässige Bereitstellungen.

**Brücke zwischen Konsole und Code**  
Sie müssen sich nicht zwischen der Verwendung von AWS-Managementkonsole oder Infrastructure-as-Code (IaC) entscheiden. Sie können beide Ansätze zusammen verwenden.

**Beschleunigte Entwicklung**  
Schneller Einstieg mit Automatisierungscode, der für den Produktionseinsatz weiter angepasst werden kann.

## Beispielanwendungsfälle
<a name="example-use-cases"></a>
+ Erstellen von DynamoDB-Tabellen mit bestimmten Attributen, Schlüsseln und Kapazitätseinstellungen
+ Einrichtung von globalen sekundären Indizes und lokalen sekundären Indizes
+ Konfiguration von Auto-Scaling-Richtlinien für DynamoDB-Tabellen
+ Einrichten von Konfigurationen für Backup und Wiederherstellung
+ Erstellen und Verwalten von DynamoDB Streams

## Erste Schritte
<a name="getting-started"></a>

So starten Sie die Verwendung Console-to-Code mit DynamoDB:

1. Melden Sie sich bei der an AWS-Managementkonsole und öffnen Sie die DynamoDB-Konsole unter. [https://console.aws.amazon.com/dynamodbv2/](https://console.aws.amazon.com/dynamodbv2/)

1. Beginnen Sie mit der Erstellung oder Änderung von DynamoDB-Ressourcen über die Konsolenschnittstelle.

1. Verwenden Sie die Console-to-Code Funktion, um Code für Ihre Aktionen in Ihrem bevorzugten Format zu generieren.

1. Kopieren Sie den generierten Code oder laden Sie ihn herunter und passen Sie ihn nach Bedarf an Ihre spezifischen Anforderungen an.

Weitere Informationen und detaillierte Anweisungen zur Verwendung Console-to-Code finden Sie unter [Automatisieren AWS-Services mit Amazon Q Developer Console-to-Code](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/console-to-code.html) im *Amazon Q Developer User Guide*.