Hadoop HBase

How to Create Table in HBase

Creating a table in HBase is different from what we were doing in RDBS. In this HBase create table tutorial, I will be telling all the methods to Create Table in HBase.

HBase Create Table

As we know, HBase is a column-oriented database like RDBS and so table creation in HBase is completely different from what we were doing in MySQL or SQL Server. It is built on the top of Hadoop file.

HBase resides at the top of Hadoop file system (HDFS) and provides read/write access.

HBase Create Table- Creating a Table using HBase Shell

We are using the same create command in HBase as well to create HBase Table. But the difference is the column family name.

We should specify the table name and the column family name while creating an HBase Table.

HBase is a NoSQL database and works on (key, value) pair. Here Key & value will be of type bytearray.

Syntax to Create Table in HBase

Let me share an example to explain the HBase Table Creation in a better way.

Let’s say we have a table like below in RDBMS SQL Server-

Id Name Salary
101 John 100k
102 Chris 200k

The above table is in Row Format as supported by SQL Server. Now how this table will behave if it will be in HBase.

Let’s see here-

Id 101 102
Name John Chris
Salary 100k 200k

Found differences?

All the rows have become column here. Now let’s see HBase Create Table Syntax.

HBase Create Table

Create command is used to create table in HBase followed by the table name and column families as below-

create ‘<Table Name>’, ‘<Column Family Name>’

HBase Create Table Example

Let’s say we have to create the above table name “Employee”.

create ‘Employee’, ‘Personal Data’, ‘Career Data’

Once your table is created, you can check the table with the help of list command.

Just simply execute the list command and it will display all the available tables.

hbase(main):002:0> list

And the output will be like-

TABLE
Employee
SentimentData
TwitterData

2 row(s) in 0.0750 seconds

Conclusion

That’s all about HBase Table Create. I hope you come to know about how to create a table in HBase.

In the next section, I will let you know how to insert data in HBase Table.

You can subscribe us for such simple and awesome tutorials.

 

Leave a Comment