Data Manipulation Commands

The Data manipulation commands are used to perform modification on the table data like adding data into a table, retrieving data from a table and deleting schema, etc.

Let us study these commands one by one.

1. Count

Using count command we can find the number of rows in a table.


hbase> count ‘<tablename>’


In this example we can count the number of rows in “beyondemp” table.

hbase(main)> count ‘beyondemp’

2. Put

Using put command we can insert rows into a table and update an existing cell value of the table.


Inserting rows                                                     

hbase>put ‘<table name>’,’row1′,'<colfamily:colname>’,'<value>’

Updating existing cell

hbase>put ‘table name’,’row’,’Colfamily:colname’,’newvalue’


* In this example firstly will insert few rows into “beyondemp” table.

hbase(main)> put ‘beyondemp’,’1′,’personal data:name’,’ravi’

> put ‘beyondemp’,’1′,’personal data:city’,’bangalore’

hbase(main)> put ‘beyondemp’,’1′,’professional data:designation’,’developer’

> put ‘beyondemp’,’1′,’professional data:salary’,’60000′

* In this example will update the city value of the employee named ‘Ravi’ to ‘Delhi’ and verify using scan command.

hbase(main)> put ‘beyondemp’,’1′,’personal data:city’,’Delhi’

 3. Get

Using get command we can read data from a table in HBase.

Note: At a time we can get only single row of data.


hbase> get ‘<table name>’,’row1′


* In this example let us scan the first row of the “beyondemp” table.

hbase(main)> get ‘beyondemp’, ‘1’

* In this example will read a specific column in HBase table.

hbase(main)> get ‘beyondemp’, ‘1’, {COLUMN ⇒ ‘personal data:name’}

4. Delete

Using delete command we can delete a specific cell in a table.


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


In this example we are deleting city column from the personal data column family and verifying with scan command.

hbase(main)> delete ‘beyondemp’, ‘1’, ‘personal data:city’,1520401439567

5. Deleteall

Using deleteall command we can delete all the cells in a row.


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


In this example we are deleting all the cells of row1 of “beyondemp” table and verifying with scan command.

hbase(main)> deleteall ‘beyondemp’,’1′

6. Truncate

Using this command we can perform two functions like disabling dropped table and recreates a table.


hbase> truncate ‘table name’


In this example will truncate the “beyondemp” table.

hbase(main)> truncate ‘beyondemp’

Note: After truncating the table, use the scan command to verify it will display table with zero rows.

7. Scan

Using scan command we can display the entire content of the table.


hbase> scan ‘<table name>’


In this example we are reading data from “beyondemp” table using the scan command.

hbase(main)> scan ‘beyondemp’

Note: In order to get the timestamp of each row we can use scan command.

“that’s all about the Data manipulation commands in hbase”.