Dropping a Table using HBase Shell
Using the drop command, you can delete a table. Before dropping a table, you have to disable it.
This command is used to drop the tables matching the “regex” given in the command. Its syntax is as follows:
Before dropping a table, you must disable it.
Example
Assume there are tables named Ashok, Ashwin, Aslam, Asha, and Ashwini.
Next Tutorial HBase Shutting down Tutorial
Previous Tutorial HBase exists Tutorial
hbase> disable 'emp' 0 row(s) in 1.2530 seconds hbase> drop 'emp' 0 row(s) in 0.4045 secondsVerify whether the table is deleted using the exists command.
hbase> exists 'emp' Table emp does not exist 0 row(s) in 0.0842 secondsdrop_all
This command is used to drop the tables matching the “regex” given in the command. Its syntax is as follows:
hbase> drop_all ‘a.*’Note
Before dropping a table, you must disable it.
Example
Assume there are tables named Ashok, Ashwin, Aslam, Asha, and Ashwini.
hbase> list ashok ashwin aslam asha ashwini 5 row(s) in 0.0160 secondsAll these tables start with the letters as. First of all, let us disable all these tables using the disable_all command as shown below.
hbase> disable_all 'as.*' ashok ashwin aslam asha ashwini Disable the above 5 tables (y/n)? y 5 tables successfully disabledDisable a Table Using Java API
package com.ashok.hbase; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.MasterNotRunningException; import org.apache.hadoop.hbase.client.HBaseAdmin; public class DisableTable { public static void main(String args[]) throws MasterNotRunningException, IOException{ // Instantiating configuration class Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin class HBaseAdmin admin = new HBaseAdmin(conf); // Verifying weather the table is disabled Boolean bool = admin.isTableDisabled("emp"); System.out.println(bool); // Disabling the table using HBaseAdmin object if(!bool){ admin.disableTable("emp"); System.out.println("Table disabled successfully"); } } }
Next Tutorial HBase Shutting down Tutorial
Previous Tutorial HBase exists Tutorial
Very nice post here and thanks for it .I like this blog and really good content.
ReplyDeleteHadoop Admin Training in Chennai
Hadoop administration in Chennai
Data Analytics Courses in Chennai
IELTS Coaching centre in Chennai
Japanese Language Classes in Chennai
Best Spoken English Classes in Chennai
Hadoop Admin Training in Tambaram
Hadoop Admin Training in Anna Nagar