GeoEco.Datasets.SQLite.SQLiteTable.CreateIndex
- SQLiteTable.CreateIndex(fields, indexName, unique=False, ascending=True)
Creates an index on one or more fields of the table.
This function does not support creation of spatial indexes. It only supports creation of indexes on non-spatial fields.
If the index cannot be created, an appropriate exception will be raised. This can happen for a variety of reasons, which may include:
The underlying storage format or programming library used to access it does not support indexes.
The caller requested that an index be created on more than one field (a “composite index”) but the format or library only supports single-field indexes.
The table is read-only, or the caller does not have sufficient privileges to create indexes.
- Parameters:
fields (
listofstr) – List of fields to form the index. Minimum length꞉ 1.indexName (
str) –Name of the index to create.
Many storage formats require indexes to be named. However, if
Noneis provided, this function will attempt to create the index without a name, which is suitable for certain formats that only support a single index, or those that allow multiple single-field indexes.The name must conform to all rules imposed by the underlying storage format and programming library used to access it. The caller is expected to be aware of these rules and this function attempts to fail if any rule is violated. Certain libraries are designed to automatically modify the caller’s illegal name to a legal name. Where possible, this function overrides that behavior and tries to fail anyway.
Minimum length꞉ 1.
unique (
bool, optional) – If True, a unique index will be created. This requires each row to have a unique combination of values for the fields in the index. If the existing rows in the table do not satisfy this constraint, an exception will probably be raised, but it is up to the underlying storage format or programming library to raise it (this function itself does not enforce this constraint). If False, rows will be permitted to have duplicate combinations of values.ascending (
bool, optional) – If True, the index will be in ascending order. If False, it will be in descending order. Not all underlying storage formats and programming libraries my support this capability.