2. HBase Shell commands

This extends 1. HBase Tutorial Getting Started. You can learn HBase basics at HBase interview Questions & Answers.

Step 1: Unlike relational databases, the NoSQL databases are semi-structured, hence you can add new columns on the fly. In HBase, you can define the table name and the column family first and then new columns for a column family can be added programmatically on the fly.

The following examples shows how to create tables (e.g. student-marks, marks-summary) and column families (e.g. grades)

The unique identifier (aka primary key) is a “row key” as shown above like “Science, Maths, and English”. The column is also known as a qualifier. The column above is “marks” and value is “80, 75, 89, 90”. New columns can be added to column families. You can have any number of column families, and each column family can have can have any number of column/value or name/value pairs. It is like having a map for each column family.

Scan for table details: “grades” is the “column family‘.

Step 2: HBase stores values as bytes.

So, if you want to display byte values in other data types, for example bytes to long

Step 3: If you want to display only specific columns

Step 4: To delete all the cells in a row. For e.g to delete the “Science” row:

To remove all and start all over again:

After truncating the table, use the scan command to verify. You will get a table with zero rows.

Step 5: Counting the number of records


Categories Menu - Q&As, FAQs & Tutorials

Top