Deleting an HBase Table
Function
Delete a table using the deleteTablemethod oforg.apache.hadoop.hbase.client.Admin.
Example Code
The following code snippet belongs to the dropTable method in the HBaseSample class of the com.huawei.bigdata.hbase.examples package.
public void dropTable() { LOG.info("Entering dropTable."); Admin admin = null; try { admin = conn.getAdmin(); if (admin.tableExists(tableName)) { // Disable the table before deleting it. admin.disableTable(tableName); // Delete table. admin.deleteTable(tableName);// Note[1] } LOG.info("Drop table successfully."); } catch (IOException e) { LOG.error("Drop table failed " ,e); } finally { if (admin != null) { try { // Close the Admin object. admin.close(); } catch (IOException e) { LOG.error("Close admin failed " ,e); } } } LOG.info("Exiting dropTable."); }
Precautions
A table can be deleted only when the table is disabled. Therefore, deleteTableis used together withdisableTable,enableTable,tableExists,isTableEnabled, andisTableDisabled.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot