TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Bigdata Learnings( Hadoop, HBase,Hive and other bigdata technologies) > HBase:Delete table using HBaseAdmin API

Sourav Gulati
Site Owner
Posts: 83

In HBase, you can delete table using HBase Shell as follows:


hbase(main):002:0> disable 'mytable'

hbase(main):003:0> drop 'mytable'


However, you can also delete table using HBaseAdmin API as follows:


public class AdminDelete {

    

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

        

    Configuration conf = HBaseConfiguration.create();

    HBaseAdmin admin = null;

    

    try{

        admin=new HBaseAdmin(conf);

       }

    catch(Exception e)

       {

        e.printStackTrace();

        

       }

    

    

    if(admin.isTableAvailable("newtable")==true)

    {

    admin.disableTable("newtable");

    

    admin.deleteTable("newtable");

    System.out.println("Table Deleted");

    }

    else

    {

        System.out.println("NewTable does not exist");

    }

    

}

}





Click here for Other topics of BigData Technologies

 

February 12, 2013 at 5:06 AM Flag Quote & Reply

You must login to post.