user2623855 user2623855 - 9 months ago 49
Java Question

Is it possible to truncate and enable a HBase table using Java?

Is there a way to truncate and re-enable a htable using the Java API similar to using the following commands in the shell?

truncate 'tablename'
enable 'tablename'

Is there a better way than iterating over each row and using deleteAll?


There is no truncate as such available in the API. But, the class HBaseAdmin has all the methods you need. Have a look at :

1. public void disableTable(String tableName) throws IOException

2. public void deleteTable(String tableName) throws IOException

3. public void enableTable(String tableName) throws IOException