删除Hbase中所有表的脚本 [英] A script that deletes all tables in Hbase
本文介绍了删除Hbase中所有表的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下命令让hbase禁用和删除特定的表:
I can tell hbase to disable and delete particular tables using:
disable 'tablename'
drop 'tablename'
但是我想删除数据库中的所有表而不用硬编码任何表的名称。有办法做到这一点吗?我想通过命令行实用程序 ./ hbase shell
,而不是通过Java或Thrift。
But I want to delete all the tables in the database without hardcoding the names of any of the tables. Is there a way to do this? I want to do this through the command-line utility ./hbase shell
, not through Java or Thrift.
推荐答案
我有一个方便的脚本,使用Python Happybase 库: / p>
I have a handy script that does exactly this, using the Python Happybase library:
import happybase
c = happybase.Connection()
for table in c.tables():
c.disable_table(table)
c.delete_table(table)
print "Deleted: " + table
您需要安装Happybase才能使用此脚本,您可以将其安装为:
You will need Happybase installed to use this script, and you can install it as:
sudo easy_install happybase
这篇关于删除Hbase中所有表的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文