Updated on 2022-08-12 GMT+08:00

CREATE SECONDARY INDEX

Function

This command is used to create secondary indexes in the CarbonData tables.

Syntax

CREATE INDEX index_name

ON TABLE [db_name.]table_name (col_name1, col_name2)

AS 'carbondata'

PROPERTIES ('table_blocksize'='256');

Parameter Description

Table 1 CREATE SECONDARY INDEX parameters

Parameter

Description

index_name

Index table name. It consists of letters, digits, and special characters (_).

db_name

Database name. It consists of letters, digits, and special characters (_).

table_name

Name of the database table. It consists of letters, digits, and special characters (_).

col_name

Name of a column in a table. Multiple columns are supported. It consists of letters, digits, and special characters (_).

table_blocksize

Block size of a data file. For details, see •Block Size.

Precautions

db_name is optional.

Examples

create table productdb.productSalesTable(id int,price int,productName string,city string) stored as carbondata;

CREATE INDEX productNameIndexTable on table productdb.productSalesTable (productName,city) as 'carbondata' ;

In this example, a secondary table named productdb.productNameIndexTable is created and index information of the provided column is loaded.

System Response

A secondary index table will be created. Index information related to the provided column will be loaded into the secondary index table. The success message will be recorded in system logs.