---
title: "hbase 表重命名"
author: "thd52java"
date: "2013-12-29T12:06:40Z"
tags: []
categories: ["互联网"]
slug: "hbase"
draft: false
lastmod: "2013-12-29T12:06:40Z"
id: 1997021
url: "https://thd52java.iteye.com/blog/1997021"
---

```
hbase shell> disable 'tableName'
hbase shell> snapshot 'tableName', 'tableSnapshot'
hbase shell> clone_snapshot 'tableSnapshot', 'newTableName'
hbase shell> delete_snapshot 'tableSnapshot'
hbase shell> drop 'tableName'

```

```
void rename(HBaseAdmin admin, String oldTableName, String newTableName) {
    String snapshotName = randomName();
    admin.disableTable(oldTableName);
    admin.snapshot(snapshotName, oldTableName);
    admin.cloneSnapshot(snapshotName, newTableName);
    admin.deleteSnapshot(snapshotName);
    admin.deleteTable(oldTableName);
}
```