HBASE-8574 Add how to rename a table in th docbook

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1483998 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-05-17 21:28:30 +00:00
parent d783067a3d
commit 667a5f848b
1 changed files with 24 additions and 0 deletions

View File

@ -839,5 +839,29 @@ false
</para>
</section>
</section>
<section xml:id="table.rename"><title>Table Rename</title>
<para>In versions 0.90.x of hbase and earlier, we had a simple script that would rename the hdfs
table directory and then do an edit of the .META. table replacing all mentions of the old
table name with the new. The script was called <command>./bin/rename_table.rb</command>.
The script was deprecated and removed mostly because it was unmaintained and the operation
performed by the script was brutal.
</para>
<para>
As of hbase 0.94.x, you can use the snapshot facility renaming a table. Here is how you would
do it using the hbase shell:
<programlisting>hbase shell> disable 'tableName'
hbase shell> snapshot 'tableName', 'tableSnapshot'
hbase shell> clone 'tableSnapshot', 'newTableName'
hbase shell> delete_snapshot 'tableSnapshot'</programlisting>
or in code it would be as follows:
<programlisting>void rename(HBaseAdmin admin, String oldTableName, String newTableName) {
String snapshotName = randomName();
admin.snapshot(snapshotName, oldTableName);
admin.cloneSnapshot(snapshotName, newTableName);
admin.deleteSnapshot(snapshotName);
admin.deleteTable(oldTableName)
}</programlisting>
</para>
</section>
</chapter>