Read HBase Table using HBase shell get Command and Examples

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

Read HBase Table using HBase shell get Command

Read HBase Table using HBase shell get Command

By using HBase shell get command, you will get a row or cell contents present in the table. In addition to that you can also add additional parameters to it such as TIMESTAMP, TIMERANGE,VERSIONS, FILTERS, etc. to get a particular row or cell content.

We will use the table ‘personal’ that we have created as part of Insert data using HBase shell put command.

HBase get command Syntax

Below is the syntax for reading data from HBase tables:

get '','row_key'

HBase get command Example

Below is the example of reading rows using HBase get command:

Read data from table personal for row key 1:

hbase(main):002:0> get 'personal', '1' COLUMN CELL personal_data:age timestamp=1505285659934, value=25 personal_data:city timestamp=1505285653043, value=Bengaluru personal_data:name timestamp=1505285635428, value=Ram 3 row(s) in 0.1820 seconds hbase(main):003:0>

Read data for particular column from HBase table:

hbase(main):003:0> get 'personal', '1', 'personal_data:name'> COLUMN CELL personal_data:name timestamp=1505285635428, value=Ram 1 row(s) in 0.0440 seconds hbase(main):004:0>

Read data for multiple columns in HBase Table:

hbase(main):004:0> get 'personal', '1', ['personal_data:name', 'personal_data:city', 'personal_data:age']> COLUMN CELL personal_data:age timestamp=1505285659934, value=25 personal_data:city timestamp=1505285653043, value=Bengaluru personal_data:name timestamp=1505285635428, value=Ram 3 row(s) in 0.0100 seconds hbase(main):005:0>

Get multiple versions from one specific row and column in HBase table:

hbase(main):005:0> get 'personal', '1', 'personal_data:name',VERSION => 2> COLUMN CELL personal_data:name timestamp=1505285635428, value=Ram 1 row(s) in 0.0140 seconds hbase(main):006:0>

HBase scan command

The HBase scan command is another HBase shell command that you can use to read the table. The HBase scan command scans entire table and displays the table contents.