Step 4: Insert Data

TcaplusDB Client - Insert Command

For TcaplusDB Client Instructions, see Document.

1. Function Descriptions

This command is used to insert a record into a table. It can be operated in two ways: show declaration parameters or pass in a file.

If it is a PB table, nested fields are allowed. If it is a TDR table containing nested fields, an error will be reported when using this command.

If data with the same Key already exists, an error will be reported.

2. Initial Version

3.40.0

3. Command Syntax

## Display the value of the declaration parameter and insert a piece of data
insert into table (key1, key2, value1, vlaue2) values (1, "abc", 2, "def") [after -1] [shift none/head/tail];
## Read and insert data from a csv format file
insert into table infile result.csv [after -1] [shift none/head/tail];
## Read and insert data from an xml format file. When performing this operation, you must provide the tdr file when starting the client
insert into table infile result.xml [after -1] [shift none/head/tail] using tdr;

Parameter description:

ParameterPB TableTDR TableRequired
tableTable nameTable nameYes
keykey field namekey field nameYes
valueNon-primary key field nameNon-primary key field nameAt least one or *
afterGeneric table: Not supported.
List table: n > 0 means inserting from the nth data; n = -2 means inserting data from the head; n = -1 means inserting data from the tail; n < -2 is not supported
Generic table: Not supported.
List table: n > 0 means inserting from the nth data; n = -2 means inserting data from the head; n = -1 means inserting data from the tail; n < -2 is not supported
No
shiftIf the table size exceeds the threshold value (i.e. the maximum size of the table), you can select: none: i.e. do not expire the data; head: expire from the head; tail: expire data from the tailIf the table size exceeds the threshold value (i.e. the maximum size of the table), you can select: none: i.e. do not expire the data; head: expire from the head; tail: expire data from the tailNo
using tdrDo not supportIf using this parameter, you need to specify the TDR file corresponding to the target table through the startup parameter when starting the TcaplusDB client.
When using this parameter, if the imported data file is in XML format, the file structure should strictly meet the XML syntax requirements
No
infileRead data from fileRead data from fileNo

4. Command Example

Data file download used in the example:

  • result.xml

  • result.csv

See Table Definition Example for table definition.

tcaplus>insert into test_table (gameid,itemid,name) values (1,1,abc);

insert success

insert time: 45322 us

tcaplus>insert into test_table (gameid,itemid,name,typeid,Data,uname) values (1,1,abc,1,1,abc);

insert success

insert time: 8412 us

tcaplus> Insert into table_list (uin, name, key1) values (99,99,99) after -1 shift tail;

insert success

insert time: 22464 us

tcaplus> Insert into table_list infile result.xml  using tdr;

insert success

insert time: 9493 us

tcaplus> Insert into table_list infile result.csv;

insert success

insert time: 22368 us

5. Common Errors

Refer to Common Errors.

[TDR Generic Table][C++ SDK] Interface Description for Inserting A Record.

[TDR Generic Table] [Java SDK] Interface Description for Inserting a Record.

[TDR Generic Table] [Go SDK] Interface Description for Inserting a Record.

[TDR List Table][C++ SDK] Interface Description for Inserting a Record.

[TDR List Table][Java SDK] Interface Description for Inserting a Record.

[TDR List Table][Go SDK] Interface Description for Inserting a Record.

[PB Generic Table][C++ SDK] Interface Description for Inserting A Record.

[PB Generic Table] [Go SDK] Interface Description for Inserting a Record.

[PB Generic Table][RESTFul API] Interface Description for Inserting a Record.

[PB List Table][C++ SDK] Interface Description for Inserting a Record.

[PB List Table][Go SDK] Interface Description for Inserting a Record.

[PB List Table][RESTFul API] Interface Description for Inserting a Record.