hbase(main):024:0> exists ’emp’
Table emp does exist
0 row(s) in 0.0750 seconds
HBase – Drop a Table:-
Dropping a Table using HBase Shell
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
Verify whether the table is deleted using the exists command.
hbase(main):020:07gt; exists ’emp’
Table emp does not exist
0 row(s) in 0.0730 seconds
This command is used to drop the tables matching the “regex” given in the command. Its syntax is as follows:
hbase> drop_all ‘t.*’
Now you can delete all of them using the drop_all command as given below.
hbase(main):018:0> drop_all ‘raj.*’
Deleting a Table Using Java API
You can delete a table using the deleteTable() method in the HBaseAdmin class. Follow the steps given below to delete a table using java API.
Instantiate the HBaseAdmin class.
// creating a configuration object
Configuration conf = HBaseConfiguration.create();
// Creating HBaseAdmin object
HBaseAdmin admin = new HBaseAdmin(conf);
Disable the table using the disableTable() method of the HBaseAdmin class.
Now delete the table using the deleteTable() method of the HBaseAdmin class.
HBase – Shutting Down:-
You exit the shell by typing the exit command.
To stop HBase, browse to the HBase home folder and type the following command.
Stopping HBase Using Java API
You can shut down the HBase using the shutdown() method of the HBaseAdmin class. Follow the steps given below to shut down HBase:
HBase – Client API:
Class HBase Configuration:
Adds HBase configuration files to a Configuration. This class belongs to the org.apache.hadoop.hbase package.
HTable is an HBase internal class that represents an HBase table. It is an implementation of table that is used to communicate with a single HBase table. This class belongs to the org.apache.hadoop.hbase.client class.
This class is used to perform Put operations for a single row. It belongs to the org.apache.hadoop.hbase.client package.