创建不带哈希的 dynamodb table
Create dynamodb table without hash
我正在尝试创建一个没有散列键的 table。但我收到错误
You must specify a KeySchema list.
如何在没有任何密钥的情况下创建 table?
userAccount:
Type: AWS::DynamoDB::Table
DeletionPolicy : Retain
Properties:
TableName: userAccount
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: S
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
hashkey
对于 DynamoDB table 是必须的。没有散列键就无法创建 table。
哈希键:-
哈希键是强制性的。
The partition key of an item is also known as its hash attribute. The
term "hash attribute" derives from the DynamoDB usage of an internal
hash function to evenly distribute data items across partitions, based
on their partition key values.
排序键:-
排序键是可选的。
The sort key of an item is also known as its range attribute. The term
"range attribute" derives from the way DynamoDB stores items with the
same partition key physically close together, in sorted order by the
sort key value.
根据 aws dynamodb doc,当您创建 table 时,您 必须 指定一个主键,因为它允许识别 table。 DynamoDb 支持两种类型的主键:
1. 分区键(哈希键):
DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (physical storage internal to DynamoDB)
2。分区键和排序键:
Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key.
DynamoDB uses the partition key value as input to an internal hash
function. The output from the hash function determines the partition
(physical storage internal to DynamoDB) in which the item will be
stored. All items with the same partition key value are stored
together, in sorted order by sort key value.
这个问题的其他答案是正确的,你不能定义没有哈希键的 DynamoDB table。但是,您的问题表明您并不完全了解 DynamoDB 的工作原理。
将 DynamoDB 想象成一个无限大的文件柜。在这个文件柜里,你有无数个文件夹。每个文件夹可能包含很多文件。
因为 DynamoDB 想让在文件柜中找到任何东西变得超级容易,每个文件夹都有一个唯一标识文件夹的标签(例如 Folder1、Folder2、...、FolderN)。还可以对每个文件夹中的文件进行排序,以便您确切知道如何在每个文件夹中查找特定文件。
DynamoDB 中的哈希键(也称为分区键)就像文件夹上的标签。没有它,DynamoDB 不知道如何在文件柜中安排或检索您的文件夹。
您始终需要定义一个分区键,以便 DynamoDB 知道如何快速存储 和 获取您的数据。毕竟,这就是我们使用 DynamoDB 的原因!
我正在尝试创建一个没有散列键的 table。但我收到错误
You must specify a KeySchema list.
如何在没有任何密钥的情况下创建 table?
userAccount:
Type: AWS::DynamoDB::Table
DeletionPolicy : Retain
Properties:
TableName: userAccount
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: S
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
hashkey
对于 DynamoDB table 是必须的。没有散列键就无法创建 table。
哈希键:-
哈希键是强制性的。
The partition key of an item is also known as its hash attribute. The term "hash attribute" derives from the DynamoDB usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
排序键:-
排序键是可选的。
The sort key of an item is also known as its range attribute. The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
根据 aws dynamodb doc,当您创建 table 时,您 必须 指定一个主键,因为它允许识别 table。 DynamoDb 支持两种类型的主键:
1. 分区键(哈希键):
DynamoDB uses the partition key's value as input to an internal hash function. The output from the hash function determines the partition (physical storage internal to DynamoDB)
2。分区键和排序键:
Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key.
DynamoDB uses the partition key value as input to an internal hash function. The output from the hash function determines the partition (physical storage internal to DynamoDB) in which the item will be stored. All items with the same partition key value are stored together, in sorted order by sort key value.
这个问题的其他答案是正确的,你不能定义没有哈希键的 DynamoDB table。但是,您的问题表明您并不完全了解 DynamoDB 的工作原理。
将 DynamoDB 想象成一个无限大的文件柜。在这个文件柜里,你有无数个文件夹。每个文件夹可能包含很多文件。
因为 DynamoDB 想让在文件柜中找到任何东西变得超级容易,每个文件夹都有一个唯一标识文件夹的标签(例如 Folder1、Folder2、...、FolderN)。还可以对每个文件夹中的文件进行排序,以便您确切知道如何在每个文件夹中查找特定文件。
DynamoDB 中的哈希键(也称为分区键)就像文件夹上的标签。没有它,DynamoDB 不知道如何在文件柜中安排或检索您的文件夹。
您始终需要定义一个分区键,以便 DynamoDB 知道如何快速存储 和 获取您的数据。毕竟,这就是我们使用 DynamoDB 的原因!