HBASE Commands
Objective: To create and execute hbase commands for the following operations
>hbase shell -- open hbase terminal
1. >status -- status 'simple'
status 'detailed'
>version -- current version
2) Create table
create <tablename>, <columnfamilyname1> <columnfamilyname2>
>create 'emp', 'personal data', 'professional data'
put 'emp','1','personal data:name','raju'
put 'emp','1','personal data:city','hyderabad'
put 'emp','1','professional data:designation','manager'
put 'emp','1','professional data:salary','50000'
put 'emp','1','professional data:vechiv','50000'
put 'emp','2','personal data:name','sathish'
put 'emp','2','personal data:city','bangalore'
put 'emp','2','professional data:designation','professor'
put 'emp','2','professional data:salary','60000'
put 'emp','3','personal data:name','muthu'
put 'emp','3','personal data:city','chennai'
put 'emp','3','professional data:designation','analyst'
put 'emp','3','professional data:salary','20000'
3. To List all the tables
list
4. To describe the table.
describe 'emp'
5. To delete a table or change its settings, you need to first disable the table
using the disable command.
disable 'emp'
is_disabled command is used to find whether a table is disabled.
6. To Drop the table
drop 'emp'
7. To find whether a table is enabled.
enable 'emp'
The following commands verifies whether the table named emp is enabled. If it is
enabled, it will return true and if not, it will return false
8. Scan command is used to view the data in HBASETable. Using the scan command, you
can get the table data.
scan 'emp'
9 Using the drop command, you can delete a table. Before dropping a table, you have to
disable it.
hbase(main):018:0> disable 'emp'
0 row(s) in 1.4580 seconds
hbase(main):019:0> drop 'emp'
0 row(s) in 0.3060 seconds
10. To get the particular record
get method > get 'emp', '1'
11. To delete the particular record
delete ‘<table name>’, ‘<row>’, ‘<column name >’, ‘<time stamp>’
delete 'emp', '1', 'personal data: city’,1417521848375
12. You can count the number of rows of a table using the count command. Its
syntax is as follows:
count ‘<table name>’
count 'emp'
13. This command disables drops and recreates a table. The syntax of truncate is as
follows:
hbase> truncate 'table name'
truncate 'emp'
Outcome:
Given HBASE commands are created and executed successfully