top of page

Basic HBase Java Classes and Methods – Part 8: Disable and Delete a Table

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class AdminDeleteTable {

    public static void main(String[] args) throws IOException {

        Configuration conf = HBaseConfiguration.create();
        Connection connection = ConnectionFactory.createConnection(conf);

        try {
            Admin admin = connection.getAdmin();
            TableName tableName = TableName.valueOf("employee");

            if (admin.tableExists(tableName)) {
                System.out.print("Table exists, Deleting.. ");

                admin.disableTable(tableName);
                admin.deleteTable(tableName);

                System.out.println(" Done.");
            } else {
                System.out.println("Table does not exist.");
            }
        } finally {
            connection.close();
        }
    }
} 

Recent Posts

See All

Comments


Hi, thanks for stopping by!

I'm a paragraph. Click here to add your own text and edit me. I’m a great place for you to tell a story and let your users know a little more about you.

Let the posts
come to you.

Thanks for submitting!

  • Facebook
  • Instagram
  • Twitter
  • Pinterest
bottom of page