A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/developer-guide/python-connector/../../sql-reference/sql/create-index below:

Website Navigation


CREATE INDEX | Snowflake Documentation

CREATE INDEX

Creates a new secondary index in an existing hybrid table and populates the index with data.

The creation of an index is an online (non-blocking) operation. The hybrid table will remain available for SELECT and DML statements while the index is being built. However, if the hybrid table is not in active use and downtime is not an issue, it is recommended that you recreate the hybrid table with indexes defined. See also Create hybrid tables.

See also:

DROP INDEX , SHOW INDEXES , CREATE HYBRID TABLE , DROP TABLE , DESCRIBE TABLE , SHOW HYBRID TABLES

Syntax
CREATE [ OR REPLACE ] INDEX [ IF NOT EXISTS ] <index_name>
  ON <table_name>
    ( <col_name> [ , <col_name> , ... ] )

Copy

Parameters
index_name

Specifies the identifier for the new index. You must specify a unique name for each new index on a given hybrid table. No other secondary index with either the same name or the same ordered set of columns can exist on the hybrid table.

table_name

Specifies the name of an existing hybrid table that will hold the new index.

col_name

Specifies the name of an existing column in the hybrid table. All the requirements for index columns defined at table creation apply to column identifiers.

A hybrid table cannot contain two secondary indexes defined on the same ordered set of columns.

Columns with geospatial data types (GEOGRAPHY and GEOMETRY), semi-structured data types (ARRAY, OBJECT, VARIANT), and vector data types (VECTOR) are not supported in secondary indexes.

Access control requirements

To create an index, you must use a role that has OWNERSHIP privilege on the hybrid table.

Usage notes Examples

To run the following CREATE INDEX example, first create and load the hybrid table.

CREATE OR REPLACE HYBRID TABLE mytable (
  pk INT PRIMARY KEY,
  val INT,
  val2 INT
);

INSERT INTO mytable SELECT seq, seq+100, seq+200
  FROM (SELECT seq8() seq FROM TABLE(GENERATOR(rowcount => 100)) v);

Copy

Now you can create an index on the table.

CREATE OR REPLACE INDEX vidx ON mytable (val);

Copy

+----------------------------------+
| status                           |
|----------------------------------|
| Statement executed successfully. |
+----------------------------------+

If a failure occurs while the index is being built, the SHOW INDEXES command reports the following status:

BUILD FAILURE Index build failed. Please drop the index and re-create it.

If you decide to stop the index build, use a DROP INDEX command:

+-------------------------------------+
| status                              |
|-------------------------------------|
| Statement executed successfully.    |
+-------------------------------------+

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4