Creating first and simple table in HBase

A new HBase table is able to create using HBase shell or Java API.

Create table in HBase:  =>  create ‘tablename’, {NAME => ‘columnname’}

 

================ ! Here we are creating table and specifying the name of table and defining two columns – Address and Order. ========

hbase(main):026:0> create ‘Customer’, {NAME => ‘Address’}, {NAME => ‘Order’}

0 row(s) in 1.3410 seconds

 

=> Hbase::Table – Customer

 

=========!  Then, we are specifying the rowkey (‘smithj’), adding the value ‘Central Dst’ for the street column in the Address column family. ========

hbase(main):030:0* put ‘Customer’, ‘smithj’, ‘Address:Street’, ‘Central Dst’

0 row(s) in 0.0210 seconds

 

==========! Here we add the value 2/2/15 for the OrderDate column in the Order column family for rowkey smithj =====================

hbase(main):033:0* put ‘Customer’, ‘smithj’, ‘Order:Date’, ‘2/2/15’

0 row(s) in 0.0160 seconds

 

=============! Here we put new records for rowkey spata. We define address in AddressCity column of Address column group. =============

hbase(main):037:0* put ‘Customer’, ‘spata’, ‘Address:city’, ‘Columbus’

0 row(s) in 0.0130 seconds

 

=============! ==============

hbase(main):038:0> put ‘Customer’, ‘spata’, ‘Address:Date’, ‘1/3/14’

0 row(s) in 0.0380 seconds

=====================! Here we retrieve the latest version in all the columns in all the families for smithj    !================================

hbase(main):040:0> get ‘Customer’, ‘smithj’

COLUMN                       CELL

Address:Street              timestamp=1462359318607, value=Central Dst

Order:Date                  timestamp=1462359568584, value=2/2/15

2 row(s) in 0.0670 seconds

 

==================! Scan statement retrieve entire table ==================

hbase(main):043:0* scan ‘Customer’

ROW                          COLUMN+CELL

smithj                      column=Address:Street, timestamp=1462359318607, value=Central Dst

smithj                      column=Order:Date, timestamp=1462359568584, value=2/2/15

spata                       column=Address:Date, timestamp=1462360002755, value=1/3/14

spata                       column=Address:city, timestamp=1462359785638, value=Columbus

2 row(s) in 0.0950 seconds

 

=================! Describe statement retrieve description of the table ===============================

hbase(main):047:0* describe ‘Customer’

Table Customer is ENABLED

Customer

COLUMN FAMILIES DESCRIPTION

{NAME => ‘Address’, DATA_BLOCK_ENCODING => ‘NONE’, BLOOMFILTER => ‘ROW’, REPLICATION_SCOPE => ‘0’, VERSIONS

=> ‘1’, COMPRESSION => ‘NONE’, MIN_VERSIONS => ‘0’, TTL => ‘FOREVER’, KEEP_DELETED_CELLS => ‘FALSE’, BLOCKSI

ZE => ‘65536’, IN_MEMORY => ‘false’, BLOCKCACHE => ‘true’}

{NAME => ‘Order’, DATA_BLOCK_ENCODING => ‘NONE’, BLOOMFILTER => ‘ROW’, REPLICATION_SCOPE => ‘0’, VERSIONS =>

‘1’, COMPRESSION => ‘NONE’, MIN_VERSIONS => ‘0’, TTL => ‘FOREVER’, KEEP_DELETED_CELLS => ‘FALSE’, BLOCKSIZE

=> ‘65536’, IN_MEMORY => ‘false’, BLOCKCACHE => ‘true’}

2 row(s) in 0.2240 seconds

 

 

Advertisements
This entry was posted in Hadoop, HBase. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s