结构体
CREATE INDEX index_name
ON TABLE base_table_name (col_name, ...)
AS 'index.handler.class.name'
[WITH DEFERRED REBUILD]
[IDXPROPERTIES (property_name=property_value, ...)]
[IN TABLE index_table_name]
[PARTITIONED BY (col_name, ...)]
[
[ ROW FORMAT ...] STORED AS ...
| STORED BY ...
]
[LOCATION hdfs_path]
[TBLPROPERTIES (...)]
例:
CREATE INDEX inedx_salary ON TABLE employee(salary) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;
改变指数
ALTER INDEX index_name ON table_name [PARTITION(...)
] REBUILD
掉落指数
DROP INDEX <index_name> ON <table_name>
如果在 CREATE INDEX 上指定了 WITH DEFERRED REBUILD,则新创建的索引最初为空(无论表是否包含任何数据)。
ALTER INDEX REBUILD 命令可用于为所有分区或单个分区构建索引结构。