HBase Delete Row using HBase shell Command and Examples

  • Post author:
  • Post last modified:February 27, 2018
  • Post category:BigData
  • Reading time:3 mins read

The set of HBase basic operations are referred to as CRUD operations. i.e. create, read, update, delete operations. HBase delete operation is nothing but delete command in HBase shell. The delete command is used to delete data from HBase tables. In this article, we will check HBase delete row using HBase shell command and some examples.

HBase Delete Row using HBase shell Command

HBase Delete Row using HBase shell Command

HBase shell delete command will delete cell value at defined table of row or column in the HBase table. You can even delete the entire row of the HBase table based on the row key.

In order to delete HBase table cell, delete command should match the cells coordinates. Using the Hbase shell delete command, you can delete a specific cell in a table.

HBase Delete command Syntax

The syntax of delete command is as follows:

delete '<table_name>', '<row_key>', '<column_name >', <time_stamp_value> 
deleteall '<table_name>', '<row_key>'

HBase Delete Command Example

To demonstrate the HBase delete command, we will use the ‘personal’ table that we have created and populated as part of Insert data using HBase shell put command.

HBase delete row using deleteall shell command

Below example to delete row cell from HBase table:

hbase(main):006:0> delete 'personal','2','personal_data:age',1505286495492

0 row(s) in 0.0140 seconds

Delete Entire Row from HBase Table using deleteall command

Below is the example to delete entire row from the HBase table using deleteall command. You can delete all cells from row in a single go using ‘deleteall’ command.

hbase(main):002:0> deleteall 'personal','1'

0 row(s) in 0.3270 seconds

Delete HBase Rows based on Range

You cannot delete the multiple rows using range in HBase shell. You can do that using Java API’s or writing script wrapper using shell, Python etc

Now verify the table using ‘scan’ command to check cells are removed from table.

hbase(main):012:0> scan 'personal'
ROW COLUMN+CELL
 2 column=personal_data:city, timestamp=1505286495492, value=Bengaluru
 2 column=personal_data:name, timestamp=1505286495492, value=sham
 3 column=personal_data:age, timestamp=1505286495492, value=27
 3 column=personal_data:city, timestamp=1505286495492, value=New Delhi
 3 column=personal_data:name, timestamp=1505286495492, value=Guru
 4 column=personal_data:age, timestamp=1505286495492, value=26
 4 column=personal_data:city, timestamp=1505286495492, value=NY
 4 column=personal_data:name, timestamp=1505286495492, value=John
 5 column=personal_data:age, timestamp=1505286495492, value=30
 5 column=personal_data:city, timestamp=1505286495492, value=DC
 5 column=personal_data:name, timestamp=1505286495492, value=Rock
4 row(s) in 0.0320 seconds

hbase(main):013:0>

Read: