dbshell insert

Description

The dbshell insert command adds documents to JSON tables. Specify the ID of the document in one of two ways:

  • As the value of the _id field in the document
  • As the value of the --id parameter in the insert command

If a document with the specified ID already exists, the command replaces the document with the new one.

Parameters

insert Options Description

*, --t, --table

(Required)

Table path
--id ID of the document to insert or replace

--v, --value

(Required)

JSON document to insert or replace
--c, --where

OJAI condition, in JSON format

The condition must qualify to perform the insert. See OJAI Query Condition Syntax for a description of the syntax.

Syntax

insert --table <table path> --value '{"_id": "<row-key", < table field >}'
insert --table <table path> --id <row-key> --value '{"_id": "<row-key", < table field >}'

Example: Insert with _id Field

The following examples insert a document into a table using an _id field value:

insert /data/movies --value '{"_id":"movie0000002", 
                              "title":"Developers on the Edge", 
                              "studio":"Command Line Studios"}'  
insert /tables/users --value '{"_id":"user001", 
                               "first_name":"John", 
                               "last_name":"Doe"}'

Example: Insert with --id Parameter

The following examples insert a document into a table using the --id parameter in the insert command:

insert /data/movies --id movie0000003 --value '{"title":"The Golden Master", 
                                                "studio":"All-Nighter"}'
insert /tables/users --id user002 --value '{"first_name":"Jane", 
                                            "last_name":"Dane"}'