更新时间:2024-11-28 GMT+08:00
删除数据
功能简介
HBase通过Table实例的delete方法来Delete数据,可以是一行数据也可以是数据集。
具体删除方法根据用户使用场景选取。
代码样例
public void testDelete() { LOG.info("Entering testDelete."); byte[] rowKey = Bytes.toBytes("012005000201"); Table table = null; try { // Instantiate an HTable object. table = conn.getTable(tableName); // Instantiate a Delete object. Delete delete = new Delete(rowKey); // Submit a delete request. table.delete(delete); LOG.info("Delete table successfully."); } catch (IOException e) { LOG.error("Delete table failed " ,e); } finally { if (table != null) { try { // Close the HTable object. table.close(); } catch (IOException e) { LOG.error("Close table failed " ,e); } } } LOG.info("Exiting testDelete."); }
父主题: 样例代码说明