wiki:waue/2010/0204-05
close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_delta.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.

範例五: 刪除資料表

執行方法

測試用打包檔 tsmcHBase_100204.jar

$ /opt/hadoop/bin/hadoop jar tsmcHBase_100204.jar DropTable

程式碼

package tsmc;

import java.io.IOException;

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

public class DropTable {

  static void drop(String tablename) {
    HBaseConfiguration conf = new HBaseConfiguration();
    HBaseAdmin admin;
    try {
      admin = new HBaseAdmin(conf);
      if (admin.tableExists(tablename))
      {
        admin.disableTable(tablename);
        admin.deleteTable(tablename);
        System.out.println("Droped the table [" + tablename+ "]");
      }else{
        System.out.println("Table [" + tablename+ "] was not found!");
      }
      
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public static void main(String[] argv) {
    drop("testtable");
  }
}

Last modified 16 years ago Last modified on Feb 5, 2010, 12:00:13 AM