HBase Tutorial
HBase Resources
Selected Reading
- HBase - Security
- HBase - Count & Truncate
- HBase - Scan
- HBase - Delete Data
- HBase - Read Data
- HBase - Update Data
- HBase - Create Data
- HBase - Client API
- HBase - Shutting Down
- HBase - Drop a Table
- HBase - Exists
- HBase - Describe & Alter
- HBase - Enabling a Table
- HBase - Disabling a Table
- HBase - Listing Table
- HBase - Create Table
- HBase - Admin API
- HBase - General Commands
- HBase - Shell
- HBase - Installation
- HBase - Architecture
- HBase - Overview
- HBase - Home
HBase Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
HBase - Exists
HBase - Exists
Existence of Table using HBase Shell
You can verify the existence of a table using the exists command. The following example shows how to use this command.
hbase(main):024:0> exists emp Table emp does exist 0 row(s) in 0.0750 seconds ================================================================== hbase(main):015:0> exists student Table student does not exist 0 row(s) in 0.0480 seconds
Verifying the Existence of Table Using Java API
You can verify the existence of a table in HBase using the tableExists() method of the HBaseAdmin class. Follow the steps given below to verify the existence of a table in HBase.
Step 1
Instantiate the HBaseAdimn class // Instantiating configuration object Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin class HBaseAdmin admin = new HBaseAdmin(conf);
Step 2
Verify the existence of the table using the tableExists( ) method.
Given below is the java program to test the existence of a table in HBase using java API.
import java.io.IOException; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.cpent.HBaseAdmin; pubpc class TableExists{ pubpc static void main(String args[])throws IOException{ // Instantiating configuration class Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin class HBaseAdmin admin = new HBaseAdmin(conf); // Verifying the existance of the table boolean bool = admin.tableExists("emp"); System.out.println( bool); } }
Compile and execute the above program as shown below.
$javac TableExists.java $java TableExists
The following should be the output:
trueAdvertisements