hbase 表重命名

来源:互联网 发布:php短信接口怎么写 编辑:程序博客网 时间:2024/06/10 20:40

hbase shell:
01.hbase shell> disable 'tableName'
02.hbase shell> snapshot 'tableName', 'tableSnapshot'
03.hbase shell> clone_snapshot 'tableSnapshot', 'newTableName'
04.hbase shell> delete_snapshot 'tableSnapshot'
05.hbase shell> drop 'tableName'
06.

java code:
01.void rename(HBaseAdmin admin, String oldTableName, String newTableName) {
02. String snapshotName = randomName();
03. admin.disableTable(oldTableName);
04. admin.snapshot(snapshotName, oldTableName);
05. admin.cloneSnapshot(snapshotName, newTableName);
06. admin.deleteSnapshot(snapshotName);
07. admin.deleteTable(oldTableName);
08.}

原创粉丝点击