Big Data Hadoop HBase

HBase Namespace Commands and Examples

In last few days, we have talked a lot about the namespace in our Hadoop federation vs high availability post. And we are going to see this namespace form HBase prospective now.

You can create the HBase namespace to the schema of the RDBMS databases. You can have HBase create a namespace in the HBase create table and then create multiple HBase tables in that HBase namespace.

In this post, we are going to talk about HBase namespace commands, HBase create namespace and HBase namespace examples.

Hbase namespace commands and examplesHBase namespace Commands

Majorly in HBase, there are 6 namespace commands and those are-

  • create_namespace
  • alter_namespace
  • describe_namespace
  • drop_namespace
  • list_namespace
  • list_namespace_tables

And we will see each of these hbase namespace commands in detail with an example in this post.

HBase create namespace command with an example

Hbase create_namespace command is being used to create a new namespace in HBase. Below is the command to be used for HBase create namespace-

Create_namespace 'namespacename'

HBase create namespace exampleAn HBase namespace can be created, removed, or updated/altered. We will see the detailed command for this Hbase namespace later here.

So, as for now, we have a namespace with name “namespacename” create in HBase. And now if we want to create an Hbase table with the name “mytable” in that namespace ” namespacename”, then we can do like below.

hbase(main):019:0> create 'namespacename:mytable','cf'
0 row(s) in 2.3760 seconds=> Hbase::Table – 'namespacename:mytable

Here mytable has been created under the “namespacename” namespace. Like any other database system, if you are not specifying any namespace in HBase, table will get created in the default namespace.

Verify the table of HBase namespace namespacename

You can verify the table just you have created under the namespace- namespacename like below-

hbase(main):020:0> list 'namespacename:mytable'
1 row(s) in 0.0050 seconds
=> ["namespacename:mytable "]

This shows that the table has been created in the namespace we have specified.

HBase Alter Namespace

Alter_namespace command is being used to alter the created namespace in HBase. Below is the example to alter namespace in HBase which we are doing on the namespace we created above.

hbase(main):046:0> alter_namespace 'namespacename', {METHOD => 'set', 'PROERTY_NAME' => 'PROPERTY_VALUE'}
0 row(s) in 0.1230 seconds

HBase Describe Namespace

Describe_namespace is being used to describe the existing namespace in HBase. Below is the command to describe the namespace in HBase.

hbase(main):047:0> describe_namespace 'namespacename'
{NAME => ' namespacename ', PROERTY_NAME => 'PROPERTY_VALUE'}
1 row(s) in 0.0050 seconds

HBase Limit Namespace Command

If you want to view or display all the namespaces available in HBase, then you can use the list_namespace command in HBase.

Below is the command that is being used to display all the namespaces in HBase-

hbase(main):048:0> list_namespace
3 row(s) in 0.0620 seconds

HBase List Namespace Table Command

HBase list_namespace_table command is being used to list or display all the tables created in a given namespace. Here the namespace name will the name for which you are looking to find the tables.

Below is the command to display all the tables of the namespace “namespacename”-

hbase(main):050:0> list_namespace_tables 'namespacename'
1 row(s) in 0.0550 seconds

HBase Drop Namespace Command

HBase drop_namespace command is being used to drop a namespace from HBase. Let me try dropping the namespace we have created “namespacename”. To drop a namespace in HBase, we will use the below command-

hbase(main):044:0> drop_namespace 'namespacename'
0 row(s) in 0.0540 seconds

One thing you should note here is, you can only drop the empty namespace. So, if you are looking to drop any namespace, you first need to drop all the tables created in that Namespace.


These were all about the namespace in HBase. We have seen HBase create namespace, HBase alters namespace, HBase delete namespace, and how to create a table in a given namespace in HBase.

Do try these HBase namespace commands and let us know for any issue or query.

Leave a Comment