Hapus satu baris dari tabel Tablestore menggunakan Tablestore SDK untuk Java.
Prasyarat
Client telah diinisialisasi. Untuk informasi selengkapnya, lihat Initialize a Tablestore client.
Metode
public DeleteRowResponse deleteRow(DeleteRowRequest deleteRowRequest) throws TableStoreException, ClientException
Kode contoh
Contoh berikut menghapus baris dengan nilai kunci primer row1 dari tabel test_table.
public static void deleteRowExample(SyncClient client) {
// Buat kunci primer.
PrimaryKeyBuilder primaryKeyBuilder = PrimaryKeyBuilder.createPrimaryKeyBuilder();
primaryKeyBuilder.addPrimaryKeyColumn("id", PrimaryKeyValue.fromString("row1"));
PrimaryKey primaryKey = primaryKeyBuilder.build();
// Buat data baris yang akan dihapus.
RowDeleteChange rowDeleteChange = new RowDeleteChange("test_table", primaryKey);
// Panggil metode deleteRow untuk menghapus data baris.
DeleteRowRequest deleteRowRequest = new DeleteRowRequest(rowDeleteChange);
DeleteRowResponse deleteRowResponse = client.deleteRow(deleteRowRequest);
// Tampilkan hasilnya.
System.out.println("RequestId: " + deleteRowResponse.getRequestId());
System.out.println("Read CU Cost: " + deleteRowResponse.getConsumedCapacity().getCapacityUnit().getReadCapacityUnit());
System.out.println("Write CU Cost: " + deleteRowResponse.getConsumedCapacity().getCapacityUnit().getWriteCapacityUnit());
}