Starting with HBase Shell Commands
2.1 HBase shell commands
HBase shell provide the commands which are used to communicate with hbase.
- whoami: It gives the information about the user.
- status: It gives the status of HBase. Its syntax is as follows:
- table_help: It gives help for table-reference commands. Its syntax is as follows:-
- version: It gives the version of HBase being used. Its syntax is as follows:
Data Definition Language
These are the commands that operate on the tables in HBase.
- create– It is used to creates a table.
create ‘<table name>’,’<column family>’
- disable– It is used to disables a table.
Hbase>disable ‘table name’
- is_disabled– It verifies that whether a table is disabled.
hbase> is_disabled 'table name'
- list– It is used to lists all the table.
- enable–It is used to enables a table.
hbase>enable ‘table name’
- is_enabled– It verifies that whether a table is enabled.
hbase> is_enabled 'table name'
- exit – It is used to exit the shell.
- alter– This command is used to alter the table
hbase>alter ‘table name’, 'conditions'
- exists– It verifies that whether a table exists.
hbase>exists ‘table name’
- describe– It gives the description of a table.
hbase> describe 'table name'
- drop– It drops a table from HBase. Drop means complete deletion of table. For this first disable the table then drop it.
hbase> disable ‘table name’
hbase> drop ‘table name’
- drop_all– It is used to drop the tables matching the ‘regex’ given in the command.
Regex is the term which specify the table name like if you want to delete those table which are start from f then regex will be f.*
- Java Admin API– Java gives an Admin API to achieve DDL functionalities through programming. Package apache.hadoop.hbase.client contains two classes, HBaseAdmin and HTableDescriptor that provide DDL functionalities.
Data manipulation language
- put– It is used to put a cell value at a specified column in a specified row in a particular table. Using this command, we can insert rows into a table. Its syntax is as follows:
hbase>put ’<table name>’,’row’,’<columnfamily:columnname>’,’<value>’
- delete– It is used to delete a cell value in a table.
hbase>delete ‘<table name>’, ‘<row>’, ‘<column name >’, ‘<time_stamp>’
- deleteall– It deletes all the cells in a given row.
hbase>deleteall ‘<table name>’, ‘<row>’
- get– It is used to read the contents of row or a cell.
hbase>get ’<table name>’,’row’
- count– It counts and returns the number of rows in a specified
hbase>count ‘<table name>’
- scan– It is used to scan and then return the table data.
hbase>scan ‘<table name>’
- truncate– It is used to disables, drop, and recreate a specified table.
hbase>truncate 'table name'
- Java client API-Java provides a client API to obtain DML functionalities. org.apache.hadoop.hbase.client package has HTable Put and Get are the classes which are used to perform CRUD(create, retrieve, update, delete) operation
2. 2 Commands for Security:-
Following commands are used to provide the security of the database from unauthorized access.
- grant – It is used to give specific rights such write, execute, read and admin on a table to a particular user.
hbase>grant <username> <permissions> [<tablename> [<column _family> [<column; qualifier>]]
- user_permission – It gives the list of all the permissions for a specified table.
- revoke – It is used to revoke a user’s access rights of a table. Its syntax is as follows:
hbase> revoke <user>
This blog will help you get a better understanding of Hbase!