Table of contents
1.
Introduction
2.
General Commands
2.1.
Status
2.2.
Table help
2.3.
Whoami
2.4.
Version
3.
Data Definition Commands
3.1.
Create
3.2.
List
3.3.
Disable
3.4.
Disable all
3.5.
Enable
3.6.
Show filter
3.7.
Drop
3.8.
Drop all
3.9.
Alter
4.
Data Manipulation Commands
4.1.
Count
4.2.
Append
4.3.
Delete
4.4.
Put
4.5.
Get
4.6.
Getcounter
4.7.
Truncate
4.8.
Incr
5.
Frequently asked questions
6.
Key takeaways
Last Updated: Mar 27, 2024
Easy

HBase Commands

Author Ankit Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

There are multiple types of databases. One among these is NoSQL. HBase is a NoSQL type of database made on top of Hadoop. With every passing moment, data is getting huge, and handling such a tremendous amount of data. The world badly needed a non-relational database. Thus NoSQL, usually referred to as a non-relational database system, was developed.

The NoSQL database was further divided into its types, and the HBase was categorized into the column-oriented database. In this article, we will cover the HBase commands in detail.

The HBase consists of various types of commands which are given below.

  1. General commands
  2. Data definition commands
  3. Data manipulation commands.
  4. Other HBase shell commands

To handle big data Hadoop, we must familiarize ourselves with the concept of HBase and to do that, We should have a clear understanding of HBase commands.

Let us begin by discussing the general commands in HBase.

Also see, Multiple Granularity in DBMS

General Commands

The HBase general commands consist of the following commands.

  1. Status
  2. Table help
  3. Whoami
  4. version

Status

As the name suggests, This command displays the system's status like several active servers present in the cluster, dead servers, and the server's average load.

Following is the syntax for this command

HBase(main):009:0> status.

We can also add different parameters depending on how detailed the system's status we want to know. By default, it will have the 'summary' parameter. We can use the other two parameters, 'simple' and 'detailed.'

Following is the syntax for using the server command with the simple parameter.

HBase(main):009:0> status ‘simple’

Table help

This HBase command guides us with different table reference commands. The following is the syntax for it.

HBase(main):007:0> table_help

Whoami

It displays the current user details from the HBase cluster.

It will provide information like the groups present in the HBase cluster, the name of the user, etc.

Following is the syntax for it.

HBase(main):009:0> whoami

Version

This command will give details of the current version of the HBase shell.

Following is the syntax for it.

HBase(main):009:0> version

Let us now move towards the Data definition commands in the HBase shell.

Data Definition Commands

These commands are the ones that help to create, alter, delete a table.

Let us discuss these commands in brief.

Create

This command is used to create a table in the HBase cluster. Let us look at its syntax.

create <tablename>, <columnfamilyname>

We can use the' list' command to display the tables to check whether the table has been successfully created in the HBase cluster. Let us discuss this command separately.

List

This command is used to display all the tables present in the database.

It follows a straightforward syntax which is given below.

hbase>list

Disable

If we want to delete or drop a table, we need first to disable it, and We can do this with the help of the 'disable' command. Its syntax is given below.

disable <tablename>

Disable all

This command will disable all the tables with matching the regular expression. Given below is its syntax.

disable_all 'matching the regular expression.'

Enable

This command is used to enable the table. Just we need to write-enable along with the table name to execute this command in the HBase shell.

Show filter

This command is used to show all the filters in the database. Following is the syntax for it.

hbase> show_filter

Drop

This command is used to delete the table permanently. To permanently delete a table from the database, we need to make sure the table is disabled first.

Following is the syntax for it.

drop<tablename>

Drop all

This command will delete all the table which matches the regular expression or the regex.

The syntax for it is given below.

drop_all <”regex”>

Alter

The Alter command is one of the most critical data definition commands in the HBase, as it helps to add/modify/delete column families.

Let us look at its syntax for adding a column family.

alter ‘tablename’, Name =>’columnfamilyname’, VERSIONS => version_number

Suppose we want to delete a column name from the table, then we can use the following syntax.

Alter ‘tablename’ , delete => ‘columnname’

This was all about the data definition commands. Let us now discuss the data manipulation commands in the HBase.

Data Manipulation Commands

Once we are done creating a table, we need to insert data into it and perform critical operations. The Data manipulation commands help us to do that.

Let us discuss these commands in detail.

Count

It will display many rows inside the table. Following is the syntax of it.

Count 'table name.'

Append

This command appends a cell value at specified table/row/column coordinates.

Delete

This command will delete the cell value at the defined table, row, or column.

Following is its syntax.

Delete ‘tablename’, ‘columnname’, ‘rowname’

Put

This command will put a cell value at a specified table/column/row.

Following is its syntax.

Put ‘tablename’,’columnname’, ‘rowname’,’value’

Get

This command will return the content of a row or a cell. Its syntax is given below.

Get ‘tablename’, ‘rowname’

This was all about the data manipulation commands, marking the end of the article. We tried to cover almost all of the essential orders in the HBase shell, but several other commands are beyond this blog's scope. Let us now see some of the frequently asked questions related to this topic.

Getcounter

This command returns a counter cell value at specified table/row/column coordinates. 

Truncate

This command disables, drop and recreates the specified table.

Incr

This command increments the cell value at specified positions. It follows the following syntax.

Incr ‘t1’,’r1’’c1’

Frequently asked questions

1. What are the other commands in HBase?

The Other commands include the following

  1. Admin commands
  2. Replication commands
  3. Snapshot commands
  4. Security commands

2. Name some of the data definition commands in the HBase?

Following are some commands from DDL

  1. Create
  2. Disable
  3. Drop
  4. Show filter

3. Name some of the data manipulation commands in the Hbase?

Following are some of the commands in DML.

  1. Append
  2. Count
  3. Delete
  4. Put
  5. Get

4. Name some of the general commands in the HBase?
Following are some of the general commands in the Hbase.

  1. Status
  2. Enable
  3. Show filter
  4. Drop
  5. Drop all

5. Hbase is which type of database?
Hbase is a NoSQL type of database, which is made on the top of Hadoop.

Key takeaways

In this blog, we discussed a Non-relation database management system named HBase. We got to know about the different kinds of commands used in it. At first, discussed the general commands, then the data definition commands, and at last, we saw some of the data manipulation commands used in HBase.

Recommended Readings: ping command in linux

Ninjas! Do not limit your learning to this and explore Coding Ninjas Studio to learn more about DBMS and practice Top-100-SQL-problems.

Live masterclass