Recherche…


Structure

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 (...)]

Exemple:

CREATE INDEX inedx_salary ON TABLE employee(salary) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;

Alter Index

ALTER INDEX nom_index ON nom_table [PARTITION (...)] REBUILD

Drop Index

DROP INDEX <index_name> ON <table_name>

Si WITH DEFERRED REBUILD est spécifié dans CREATE INDEX, l'index nouvellement créé est initialement vide (que la table contienne ou non des données).

La commande ALTER INDEX REBUILD peut être utilisée pour créer la structure d'index pour toutes les partitions ou une seule partition.



Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow