Recent Posts

Sunday, 12 February 2017

HBase Exists Tutorial


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> 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
import java.io.IOException;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.HBaseAdmin;

public class TableExists{

   public 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);
   }
} 

Next Tutorial  HBase Drop Table Tutorial

Previous Tutorial  HBase Describe and Alter Tutorial

No comments:

Post a Comment