Dynamodb 简明教程
DynamoDB - API Interface
DynamoDB 提供了一系列强大的 API 工具,用于表操作、数据读取和数据修改。
DynamoDB offers a wide set of powerful API tools for table manipulation, data reads, and data modification.
Amazon 建议使用 AWS SDKs (例如,Java SDK)而不是调用低级别的 API。此类库消除了直接与低级别 API 交互的必要性。这些库简化了常见的任务,如认证、序列化和连接。
Amazon recommends using AWS SDKs (e.g., the Java SDK) rather than calling low-level APIs. The libraries make interacting with low-level APIs directly unnecessary. The libraries simplify common tasks such as authentication, serialization, and connections.
Manipulate Tables
DynamoDB 提供了五种用于表管理的低级别操作:
DynamoDB offers five low-level actions for Table Management −
-
CreateTable − This spawns a table and includes throughput set by the user. It requires you to set a primary key, whether composite or simple. It also allows one or multiple secondary indexes.
-
ListTables − This provides a list of all tables in the current AWS user’s account and tied to their endpoint.
-
UpdateTable − This alters throughput, and global secondary index throughput.
-
DescribeTable − This provides table metadata; for example, state, size, and indices.
-
DeleteTable − This simply erases the table and its indices.
Read Data
DynamoDB 提供了四种用于数据读取的低级别操作:
DynamoDB offers four low-level actions for data reading −
-
GetItem − It accepts a primary key and returns attributes of the associated item. It permits changes to its default eventually consistent read setting.
-
BatchGetItem − It executes several GetItem requests on multiple items through primary keys, with the option of one or multiple tables. Its returns no more than 100 items and must remain under 16MB. It permits eventually consistent and strongly consistent reads.
-
Scan − It reads all the table items and produces an eventually consistent result set. You can filter results through conditions. It avoids the use of an index and scans the entire table, so do not use it for queries requiring predictability.
-
Query − It returns a single or multiple table items or secondary index items. It uses a specified value for the partition key, and permits the use of comparison operators to narrow scope. It includes support for both types of consistency, and each response obeys a 1MB limit in size.
Modify Data
DynamoDB 为数据修改提供了四个底层操作 −
DynamoDB offers four low-level actions for data modification −
-
PutItem − This spawns a new item or replaces existing items. On discovery of identical primary keys, by default, it replaces the item. Conditional operators allow you to work around the default, and only replace items under certain conditions.
-
BatchWriteItem − This executes both multiple PutItem and DeleteItem requests, and over several tables. If one request fails, it does not impact the entire operation. Its cap sits at 25 items, and 16MB in size.
-
UpdateItem − It changes the existing item attributes, and permits the use of conditional operators to execute updates only under certain conditions.
-
DeleteItem − It uses the primary key to erase an item, and also allows the use of conditional operators to specify the conditions for deletion.