文档简介:
删除索引
功能简介
使用Phoenix删除二级索引。
示例代码
以下代码片段在cn.chinatelecom.hbase.sample.PhoenixSample.sampleDropIndex方法中。
/**
* Drop Index
*/
public static boolean sampleDropIndex(Configuration conf) {
log.info("Entering sampleDropIndex.");
int result = -1;
//default assume zookeeper is stand-alone, and phoenix query server is same as zookeeper
String url = "jdbc:phoenix:thin:url=http://" + conf.get("hbase.zookeeper.quorum") + ":" +
conf.get("phoenix.queryserver.http.port", "8765") +
";serialization=" + conf.get("phoenix.queryserver.serialization", "PROTOBUF");
String sql = "DROP INDEX IF EXISTS IDX_PHOENIX_SAMPLE_AGE ON PHOENIX_SAMPLE";
try (Connection conn = DriverManager.getConnection(url); Statement stat = conn.createStatement()) {
result = stat.executeUpdate(sql);
log.info("Drop index successfully.");
} catch (Exception e) {
log.error("Drop index failed.", e);
}
log.info("Exiting sampleDropIndex.");
return result >= 0;
}