INSERT command in Amazon QLDB - Amazon Quantum Ledger Database (Amazon QLDB)

INSERT command in Amazon QLDB

In Amazon QLDB, use the INSERT command to add one or more Amazon Ion documents to a table.

Note

To learn how to control access to run this PartiQL command on specific tables, see Getting started with the standard permissions mode in Amazon QLDB.

Syntax

Insert a single document.

INSERT INTO table_name VALUE document

Insert multiple documents.

INSERT INTO table_name << document, document, ... >>

Parameters

table_name

The name of the user table where you want to insert the data. The table must already exist. DML statements are only supported in the default user view.

document

A valid QLDB document. You must specify at least one document. Multiple documents must be separated by commas.

The document must be denoted by curly braces ( {...} ).

Each field name in the document is a case-sensitive Ion symbol that can be denoted by single quotation marks ('...') in PartiQL.

String values are also denoted by single quotation marks ('...') in PartiQL.

Any Ion literals can be denoted with backticks (`...`).

Note

Double angle brackets ( <<...>> ) denote an unordered collection (known as a bag in PartiQL) and are required only if you want to insert multiple documents.

Return value

documentId – The unique ID of each document that you inserted.

Examples

Insert a single document.

INSERT INTO VehicleRegistration VALUE { 'VIN' : 'KM8SRDHF6EU074761', --string 'RegNum' : 1722, --integer 'State' : 'WA', 'City' : 'Kent', 'PendingPenaltyTicketAmount' : 130.75, --decimal 'Owners' : { --nested struct 'PrimaryOwner' : { 'PersonId': '294jJ3YUoH1IEEm8GSabOs' }, 'SecondaryOwners' : [ --list of structs { 'PersonId' : '1nmeDdLo3AhGswBtyM1eYh' }, { 'PersonId': 'IN7MvYtUjkp1GMZu0F6CG9' } ] }, 'ValidFromDate' : `2017-09-14T`, --Ion timestamp literal with day precision 'ValidToDate' : `2020-06-25T` }

This statement returns the unique ID of the document that you inserted, as follows.

{ documentId: "2kKuOPNB07D2iTPBrUTWGl" }

Insert multiple documents.

INSERT INTO Person << { 'FirstName' : 'Raul', 'LastName' : 'Lewis', 'DOB' : `1963-08-19T`, 'GovId' : 'LEWISR261LL', 'GovIdType' : 'Driver License', 'Address' : '1719 University Street, Seattle, WA, 98109' }, { 'FirstName' : 'Brent', 'LastName' : 'Logan', 'DOB' : `1967-07-03T`, 'GovId' : 'LOGANB486CG', 'GovIdType' : 'Driver License', 'Address' : '43 Stockert Hollow Road, Everett, WA, 98203' }, { 'FirstName' : 'Alexis', 'LastName' : 'Pena', 'DOB' : `1974-02-10T`, 'GovId' : '744 849 301', 'GovIdType' : 'SSN', 'Address' : '4058 Melrose Street, Spokane Valley, WA, 99206' } >>

This statement returns the unique ID of each document that you inserted, as follows.

{ documentId: "6WXzLscsJ3bDWW97Dy8nyp" }, { documentId: "35e0ToZyTGJ7LGvcwrkX65" }, { documentId: "BVHPcH612o7JROQ4yP8jiH" }

Running programmatically using the driver

To learn how to programmatically run this statement using the QLDB driver, see the following tutorials in Getting started with the driver: