DROP INDEX
Deletes an existing index from a LindormTable table.
Applicable engines and versions
DROP INDEX syntax applies only to the wide table engine. No version limit applies.
To drop a search index or columnar index, the Lindorm SQL version must be 2.6.1 or later. To check your Lindorm SQL version, see SQL versions.
Syntax
DROP INDEX [IF EXISTS] index_identifier ON table_identifier;Parameters
Parameter | Description |
| Optional. If the index exists, it is dropped. If the index does not exist, the statement is a no-op and returns no error. Without |
| The name of the index to drop. |
| The name of the table that the index belongs to. |
Usage notes
Before dropping a secondary index or search index, disable the index with
ALTER INDEX ... DISABLED, then confirm it is in theDISABLEDstate usingSHOW INDEX. For details, see ALTER INDEX and SHOW INDEX.Dropping a table also drops all indexes on that table.
Examples
The following examples use this base table and its indexes:
-- Create the base table.
CREATE TABLE test (
p1 VARCHAR NOT NULL,
p2 INTEGER NOT NULL,
c1 BIGINT,
c2 DOUBLE,
c3 VARCHAR,
c4 TIMESTAMP,
PRIMARY KEY(p1, p2)
) WITH (CONSISTENCY = 'strong', MUTABILITY='MUTABLE_LATEST');
-- Create a secondary index named idx1.
CREATE INDEX idx1 ON test(c1 desc) include(c3,c4) WITH (COMPRESSION='ZSTD');
-- Create a search index named idx2.
CREATE INDEX IF NOT EXISTS idx2 USING SEARCH ON test(p1, p2, c1, c2, c3);
-- Create a columnstore index named idx3.
CREATE INDEX IF NOT EXISTS idx3 USING COLUMNAR
ON test(p1, p2, c1, c2, c3)
PARTITION BY ENUMERABLE (p1, p2, bucket(128, p1, p2));Drop a secondary index
Disable the index.
ALTER INDEX IF EXISTS idx1 ON test DISABLED;Drop the index.
DROP INDEX IF EXISTS idx1 ON test;
Verify the result
Run the following statement to confirm the index has been removed:
SHOW INDEX FROM test;Drop a search index
Disable the index.
ALTER INDEX IF EXISTS idx2 ON test DISABLED;Drop the index.
DROP INDEX IF EXISTS idx2 ON test;
Verify the result
Run the following statement to confirm the index has been removed:
SHOW INDEX FROM test;Delete a columnstore index
Execute the following statement to delete the columnstore index idx3.
DROP INDEX idx3 ON test;Verify the result
Execute the following statement to verify that the index was deleted.
SHOW INDEX FROM test;