テーブルを作成する
aws dynamodb create-table \
--table-name rhinoceros \
--attribute-definitions \
AttributeName=_p_key,AttributeType=S \
AttributeName=_id,AttributeType=S \
--key-schema AttributeName=_p_key,KeyType=HASH AttributeName=_id,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
--endpoint-url http://localhost:8000
テーブルの一覧を確認する
aws dynamodb list-tables --endpoint-url http://localhost:8000
テーブルの定義を確認する
aws dynamodb describe-table \
--table-name rhinoceros \
--endpoint-url http://localhost:8000
テーブルにデータを挿入する
aws dynamodb put-item \
--table-name rhinoceros \
--item '{"_p_key":{"S":"rhinoceros_usa"}, "_id":{"S":"1"}, "code":{"S":"RHINO1"}, "name":{"S":"なまえ1"}}' \
--endpoint-url http://localhost:8000
テーブルのデータ件数を確認する
aws dynamodb scan \
--table-name rhinoceros \
--select COUNT \
--endpoint-url http://localhost:8000
テーブルのデータを確認する
aws dynamodb scan \
--table-name rhinoceros \
--endpoint-url http://localhost:8000
テーブルのデータを確認する(条件つき)
aws dynamodb scan \
--table-name rhinoceros \
--filter-expression "#name1 = :value1 AND #name2 >= :value2" \
--expression-attribute-names '{"#name1":"_p_key", "#name2":"_id"}' \
--expression-attribute-values '{":value1":{"S":"rhinoceros_usa"}, ":value2":{"S":"-1"}}' \
--limit 25 \
--endpoint-url http://localhost:8000
テーブルのデータを1件取得する
aws dynamodb get-item \
--table-name rhinoceros \
--key '{"_p_key":{"S":"rhinoceros_usa"}, "_id":{"S":"1"}}' \
--endpoint-url http://localhost:8000
テーブルのデータを変更する
aws dynamodb update-item \
--table-name rhinoceros \
--key '{"_p_key":{"S":"rhinoceros_usa"}, "_id":{"S":"1"}}' \
--update-expression "SET #name1 = :value1, #name2 = :value2" \
--expression-attribute-names '{"#name1":"code", "#name2":"name"}' \
--expression-attribute-values '{":value1":{"S":"RHINOCEROS1"}, ":value2":{"S":"名前1"}}' \
--return-values ALL_NEW \
--endpoint-url http://localhost:8000
テーブルのデータを削除する
aws dynamodb delete-item \
--table-name rhinoceros \
--key '{"_p_key":{"S":"rhinoceros_usa"}, "_id":{"S":"1"}}' \
--endpoint-url http://localhost:8000
テーブルを削除する
aws dynamodb delete-table \
--table-name rhinoceros \
--endpoint-url http://localhost:8000
TOP >
月影丸の間 >
月影 COMPUTER >
データベース >
DynamoDB >
DynamoDB 基本コマンド