CREATE TABLE - Amazon Quantum Ledger Database (Amazon QLDB)

CREATE TABLE

Use the CREATE TABLE command to create a new table in your Amazon QLDB ledger.

Tables have simple names with no namespaces. QLDB supports open content and does not enforce schema, so you don't define attributes or data types when creating tables.

Note

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

Syntax

CREATE TABLE table [ WITH (aws_tags = `{'key': 'value'}`) ]

Parameters

table

The name of the table to create. The following are the naming constraints:

  • Must only contain 1–128 alphanumeric characters or underscores.

  • Must have a letter or an underscore for the first character.

  • Can have any combination of alphanumeric characters and underscores for the remaining characters.

  • Is case sensitive.

  • Must not be a QLDB PartiQL reserved word.

key, value

(Optional) The tag key-value pair to attach to the table resource during creation.

Return value

tableId – The unique ID of the table that you created.

Tagging tables on creation

Optionally, you can tag your table resources by specifying tags in a CREATE TABLE statement. For more information about tags, see Tagging Amazon QLDB resources. The following example creates a table named Vehicle with the tag environment=production.

CREATE TABLE Vehicle WITH (aws_tags = `{'environment': 'production'}`)

Tagging tables on creation requires access to both the qldb:PartiQLCreateTable and qldb:TagResource actions. To learn more about permissions for QLDB resources, see How Amazon QLDB works with IAM.

By tagging resources while they're being created, you can eliminate the need to run custom tagging scripts after resource creation. After a table is tagged, you can control access to the table based on those tags. For example, you can grant full access only to tables that have a specific tag. For a JSON policy example, see Full access to all actions based on table tags.

Examples

CREATE TABLE VehicleRegistration
CREATE TABLE Vehicle WITH (aws_tags = `{'environment': 'development'}`)

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: