Hbase is usually installed on the top of the Hadoop and it uses the Hadoop file system for its storage. Just like other Bigdata framework such as Hive, Pig etc, Hbase provides jruby interactive shell. You can also use various Java API to interact with HBase. In this article, we will check some commonly used HBase Data Manipulation shell commands and explanation on how to use them.
Commonly used HBase Data Manipulation Shell Commands
HBase provide many data manipulation shell commands that you can use on the interactive shell to manipulate the data. The Commonly used HBase data manipulation shell commands are: Count, Put, Get, Delete, Delete all, Truncate, Scan.
HBase Count Shell Command
This command will return the number of rows in the table. Note that, it return total number of rows not number of cells.
HBase Count Shell Command Syntax
count <’table name’> CACHE => 1000
The CACHE in above syntax represents, current count is shown per every 1000 rows by default. This CAHCE size is 10 rows by default. HBase count shell command will work fast when it is configured with right Cache size.
HBase Count Shell Command Examples
Below are the HBase count command examples:
hbase(main):002:0> count 'emp' 16 row(s) in 0.1330 seconds => 16 hbase(main):004:0> count 'emp', CACHE => 1000 16 row(s) in 0.0090 seconds => 16
You can also use the INTERVAL option along with count command.
hbase(main):009:0> count 'store_sales', INTERVAL => 100, CACHE => 1000 Current count: 100, row: 12811 Current count: 200, row: 16367 Current count: 300, row: 349 Current count: 400, row: 6758 Current count: 500, row: 98 509 row(s) in 0.0290 seconds => 509
HBase put shell command
This command is used to insert the data into HBase tables.
Read: Insert data into HBase tables using put command and examples
HBase get shell command
This command is used to read the HBase tables.
Read: Read HBase tables using get command and examples
HBase Delete and Deleteall shell command
This command is used to delete the record from the tables. You can Automatically Delete HBase row using Time to Live (TTL) Settings. Automatically expire row options helps you to remove sensitive information from the HBase once that information is used.
Read: Delete HBase row using delete command and examples
HBase Truncate Shell command
Truncate command will re-creates HBase table. This command will first disables the table, drop it and re-create given table.
HBase Scan Shell Command
This command is used to display the content of table.
Read: HBase scan shell command and example
HBase Truncate Shell command Syntax
Below is the syntax:
truncate <’table name’>
HBase Truncate Shell command Examples
Below is the example to truncate HBase table:
hbase(main):011:0> truncate 'test' Truncating 'test' table (it may take a while): - Disabling table... - Truncating table... 0 row(s) in 4.5380 seconds
Related Reading:
- HBase Exit Code – Capture Last Executed Command Status
- How to Execute HBase Commands from Shell Script? – Examples