edit-icon download-icon

Write data

Last Updated: Mar 01, 2018


In a relational database, a table is a two-dimensional data structure composed of rows and columns. You can use the INSERT statement to add rows to a table as follows.

  1. INSERT INTO UserHistory (
  2. user_id, time_stamp, item_id, behavior_type,
  3. behavior_amount, behavior_count, content)
  4. VALUES(
  5. '10100', 1479265526, 'cell_phone', 'share', 4.9, 78,
  6. 'The phone is quite good!'
  7. );

Table Store

In Table Store, you can use the PutRow API to insert a row of data as follows.

  1. // Set primary keys
  2. PrimaryKeyBuilder primaryKeyBuilder = PrimaryKeyBuilder.createPrimaryKeyBuilder();
  3. primaryKeyBuilder.addPrimaryKeyColumn("user_id", PrimaryKeyValue.fromString("10100"));
  4. primaryKeyBuilder.addPrimaryKeyColumn("time_stamp", PrimaryKeyValue.fromLong(1479265526));
  5. PrimaryKey primaryKey = primaryKeyBuilder.build();
  6. // Set the attribute column value
  7. RowPutChange rowPutChange = new RowPutChange(TABLE_NAME, primaryKey);
  8. rowPutChange.addColumn(new Column("item_id", ColumnValue.fromString("cell_phone")));
  9. rowPutChange.addColumn(new Column("behavior_type", ColumnValue.fromString("share")));
  10. rowPutChange.addColumn(new Column("behavior_amount", ColumnValue.fromDouble(4.9)));
  11. rowPutChange.addColumn(new Column("behavior_count", ColumnValue.fromLong(78)));
  12. rowPutChange.addColumn(new Column("content", ColumnValue.fromString("The phone is quite good!")));
  13. // Insert this row of data
  14. client.putRow(new PutRowRequest(rowPutChange));


  • Except for TABLE_NAME and primaryKey, attribute columns and types can be defined during data writing.
  • Attribute columns of the same names in multiple rows of data do not have to be of the same type.
  • Big data SQL databases are transaction-oriented. If an INSERT statement is issued, the data modifications are made permanently only after the COMMIT statement is received. In Table Store, when the HTTP 200 (OK) status code is returned, this means the data written by PutRow has been made permanent in all copies.
  • You can use the BatchWriteRow API to insert multiple records to dramatically improve data writing speed.
Thank you! We've received your feedback.