How do I remove attribute columns from a data table?
Data tables are schema-free. Each row of data may have different attribute columns. You cannot remove a specific attribute column from all rows in a data table at the same time.
After you obtain the primary key information of a row, you can call the UpdateRow operation to remove an attribute column of the row. In this example, Tablestore SDK for Java is used to remove the Col attribute column from a row.
private static void updateRow(SyncClient client, String pkValue) {
// Construct the primary key.
PrimaryKeyBuilder primaryKeyBuilder = PrimaryKeyBuilder.createPrimaryKeyBuilder();
primaryKeyBuilder.addPrimaryKeyColumn("<PRIMARY_KEY_NAME>", PrimaryKeyValue.fromString(pkValue));
PrimaryKey primaryKey = primaryKeyBuilder.build();
// Specify the name of the data table.
RowUpdateChange rowUpdateChange = new RowUpdateChange("<TABLE_NAME>", primaryKey);
// Remove all versions of data from the attribute column.
rowUpdateChange.deleteColumns("Col");
// Remove a specific version of data from the attribute column.
//rowUpdateChange.deleteColumn("Col", 1465373223000L);
client.updateRow(new UpdateRowRequest(rowUpdateChange));
} To remove an attribute column from multiple rows of data at the same time, call the BatchWriteRow operation.
You can write up to 200 rows of data at the same time by calling the BatchWriteRow operation. You can use the TableStoreWriter tool class to write data with high concurrency and high throughput. For more information, see Use TableStoreWriter to concurrently write data.