Deleting Data

Deleting a Specific Cell in a Table

Using the delete command, you can delete a specific cell in a table. The syntax of delete command is as follows

delete ‘<table name>’, ‘<row>’, ‘<column name >’, ‘<time stamp>’


Here is an example to delete a specific cell. Here we are deleting the salary.

hbase> delete 'emp', '1', 'personal data:city', 1217521785385
0 row(s) in 0.0050 seconds
Deleting All Cells in a Table

Using the “deleteall” command, you can delete all the cells in a row. Given below is the syntax of deleteall command.

deleteall ‘<table name>’, ‘<row>’,


Here is an example of “deleteall” command, where we are deleting all the cells of row1 of emp table.

hbase> deleteall 'emp','1'
0 row(s) in 0.0420 seconds
Deleting Data Using Java API
package com.ashok.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;

 * @author ashok.mariyala
public class DeleteData {

   public static void main(String[] args) throws IOException {

      // Instantiating Configuration class
      Configuration conf = HBaseConfiguration.create();

      // Instantiating HTable class
      HTable table = new HTable(conf, "employee");

      // Instantiating Delete class
      Delete delete = new Delete(Bytes.toBytes("row1"));
      delete.deleteColumn(Bytes.toBytes("personal"), Bytes.toBytes("name"));

      // deleting the data

      // closing the HTable object
      System.out.println("Data deleted successfully...!!");

Deleting Data
Scroll to top