Used to create an index automatically for system tables.
490844
Index createIndexForColumns(int[] columns) {

        HsqlName indexName = database.nameManager.newAutoName("IDX_T",
            getSchemaName(), getName(), SchemaObject.INDEX);

        try {
            Index index = createAndAddIndexStructure(indexName, columns, null,
                null, false, false, false, false);

            return index;
        } catch (Throwable t) {
            return null;
        }
    }
1123791
public void createRTreeIndex(String tableName, String geometryColumnName) {

		String sqlName = GeoPackageProperties.getProperty(SQL_PROPERTY,
				CREATE_PROPERTY);
		executeSQL(sqlName, tableName, geometryColumnName);
	}
1161523
def create_tables(c):
    """"""
    # auto_shape_types ---------------------
    c.execute(
        'DROP TABLE IF EXISTS auto_shape_types'
    )
    c.execute(
        'CREATE TABLE auto_shape_types (\n'
        '    id         integer,\n'
        '    prst       text,\n'
        '    const_name text,\n'
        '    base_name  text,\n'
        '    ms_name    text,\n'
        '    desc       text\n'
        ')\n'
    )
    c.execute(
        'DROP TABLE IF EXISTS adjustment_values'
    )
    c.execute(
        'CREATE TABLE adjustment_values (\n'
        '    prst     text,\n'
        '    seq_nmbr integer,\n'
        '    name     text,\n'
        '    val      integer\n'
        ')\n'
    )
1362504
def index(self, connection, partition, columns):
        

        import hashlib

        query_tmpl = '''
            CREATE INDEX IF NOT EXISTS {index_name} ON {table_name} ({columns});
        '''

        if not isinstance(columns,(list,tuple)):
            columns = [columns]

        col_list = ','.join('"{}"'.format(col) for col in columns)

        col_hash = hashlib.md5(col_list).hexdigest()

        try:
            table_name = partition.vid
        except AttributeError:
            table_name = partition # Its really a table name

        query = query_tmpl.format(
            index_name='{}_{}_i'.format(table_name, col_hash), table_name=table_name,
            columns=col_list)

        logger.debug('Creating sqlite index: query: {}'.format(query))
        cursor = connection.cursor()

        cursor.execute(query)
263123
private boolean createIndex(String index, Map<String, Object> defaultSettings) {
        IndicesExistsResponse res = client.admin().indices().prepareExists(index).execute().actionGet();
        boolean created = false;
        if (!res.isExists()) {
            CreateIndexRequestBuilder req = client.admin().indices().prepareCreate(index);
            req.setSettings(defaultSettings);
            created = req.execute().actionGet().isAcknowledged();
            if (!created) {
                throw new RuntimeException("Could not create index [" + index + "]");
            }
        }

        return created;
    }
1048945
def index(self, sort=True):
        """"""
        from casacore.tables import tableindex
        return tableindex(self._table, [self._column], sort)
87966
def register_index(self, index):
    

    self._indexes[index._name] = index
    self.create_index(index)
    return index
15173
def addIndex(self, index):
        
        index.setSchema(self)
        self.__indexes[index.name()] = index
149972
private void createTablesAndPkAndIndexes() {

        for (Table t : metadata.getTables()) {
            comment(" == TABLES [ " + t.getName() + " ] =======================");

            createTable(t);
            createIndexes(t);
            if (t.hasH2IdentityPk()) {
                line("ALTER TABLE ", t.getName(), " ALTER COLUMN ", t.getPrimaryKey(), " IDENTITY;");
            } else if (t.hasPk()) {
                line("CREATE PRIMARY KEY ON ", t.getName(), " (", toCsvString(t.getPrimaryKeys()), ");");
            }
            line("");
        }
    }
1336356
def create_index(self, key, reindex=True, sparse=False):
        
        warnings.warn('Index support is currently very alpha and is not guaranteed')
        if isinstance(key, (list, tuple)):
            index_name = ','.join(key)
            index_columns = ', '.join('%s text' % f for f in key)
        else:
            index_name = key
            index_columns = '%s text' % key

        table_name = '[%s{%s}]' % (self.name, index_name)
        reindex = reindex or not self._object_exists('table', table_name)

        # Create a table store for the index data
        self.db.execute("""
            create table if not exists {table} (
                id integer primary key,
                {columns},
                foreign key(id) references {collection}(id) on delete cascade on update cascade
            )
        """.format(
            table=table_name,
            collection=self.name,
            columns=index_columns
        ))

        # Create the index
        self.db.execute("""
            create index if not exists [idx.{collection}{{index}}] on {table}({index})
        """.format(
            collection=self.name,
            index=index_name,
            table=table_name,
        ))

        if reindex:
            self.reindex(key)
796514
def create_index(self,
                     table: str,
                     field: str,
                     nchars: int = None,
                     indexname: str = None,
                     unique: bool = False) -> Optional[int]:
        """"""
        limit = ""
        if nchars is not None:
            limit = "({})".format(nchars)
        if indexname is None:
            indexname = "_idx_{}".format(field)
        if self.index_exists(table, indexname):
            return None
        uniquestr = "UNIQUE" if unique else ""
        sql = (
            "CREATE {unique} INDEX {indexname} "
            "ON {table} ({field}{limit})".format(
                unique=uniquestr,
                indexname=indexname,
                table=table,
                field=field,
                limit=limit,
            )
        )
        return self.db_exec(sql)
342461
protected Table generateTable(int tableIndex) {

        switch (tableIndex) {

            case SYSTEM_UDTS :
                return SYSTEM_UDTS();

            case SYSTEM_VERSIONCOLUMNS :
                return SYSTEM_VERSIONCOLUMNS();

            // HSQLDB-specific
            case SYSTEM_CACHEINFO :
                return SYSTEM_CACHEINFO();

            case SYSTEM_SESSIONINFO :
                return SYSTEM_SESSIONINFO();

            case SYSTEM_PROPERTIES :
                return SYSTEM_PROPERTIES();

            case SYSTEM_SESSIONS :
                return SYSTEM_SESSIONS();

            case SYSTEM_TEXTTABLES :
                return SYSTEM_TEXTTABLES();

            // SQL views
            case ADMINISTRABLE_ROLE_AUTHORIZATIONS :
                return ADMINISTRABLE_ROLE_AUTHORIZATIONS();

            case APPLICABLE_ROLES :
                return APPLICABLE_ROLES();

            case ASSERTIONS :
                return ASSERTIONS();

            case AUTHORIZATIONS :
                return AUTHORIZATIONS();

            case CHARACTER_SETS :
                return CHARACTER_SETS();

            case CHECK_CONSTRAINT_ROUTINE_USAGE :
                return CHECK_CONSTRAINT_ROUTINE_USAGE();

            case CHECK_CONSTRAINTS :
                return CHECK_CONSTRAINTS();

            case COLLATIONS :
                return COLLATIONS();

            case COLUMN_COLUMN_USAGE :
                return COLUMN_COLUMN_USAGE();

            case COLUMN_DOMAIN_USAGE :
                return COLUMN_DOMAIN_USAGE();

            case COLUMN_UDT_USAGE :
                return COLUMN_UDT_USAGE();

            case CONSTRAINT_COLUMN_USAGE :
                return CONSTRAINT_COLUMN_USAGE();

            case CONSTRAINT_TABLE_USAGE :
                return CONSTRAINT_TABLE_USAGE();

            case COLUMNS :
                return COLUMNS();

            case DATA_TYPE_PRIVILEGES :
                return DATA_TYPE_PRIVILEGES();

            case DOMAIN_CONSTRAINTS :
                return DOMAIN_CONSTRAINTS();

            case DOMAINS :
                return DOMAINS();

            case ENABLED_ROLES :
                return ENABLED_ROLES();

            case JAR_JAR_USAGE :
                return JAR_JAR_USAGE();

            case JARS :
                return JARS();

            case KEY_COLUMN_USAGE :
                return KEY_COLUMN_USAGE();

            case METHOD_SPECIFICATIONS :
                return METHOD_SPECIFICATIONS();

            case MODULE_COLUMN_USAGE :
                return MODULE_COLUMN_USAGE();

            case MODULE_PRIVILEGES :
                return MODULE_PRIVILEGES();

            case MODULE_TABLE_USAGE :
                return MODULE_TABLE_USAGE();

            case MODULES :
                return MODULES();

            case PARAMETERS :
                return PARAMETERS();

            case REFERENTIAL_CONSTRAINTS :
                return REFERENTIAL_CONSTRAINTS();

            case ROLE_AUTHORIZATION_DESCRIPTORS :
                return ROLE_AUTHORIZATION_DESCRIPTORS();

            case ROLE_COLUMN_GRANTS :
                return ROLE_COLUMN_GRANTS();

            case ROLE_ROUTINE_GRANTS :
                return ROLE_ROUTINE_GRANTS();

            case ROLE_TABLE_GRANTS :
                return ROLE_TABLE_GRANTS();

            case ROLE_USAGE_GRANTS :
                return ROLE_USAGE_GRANTS();

            case ROLE_UDT_GRANTS :
                return ROLE_UDT_GRANTS();

            case ROUTINE_COLUMN_USAGE :
                return ROUTINE_COLUMN_USAGE();

            case ROUTINE_JAR_USAGE :
                return ROUTINE_JAR_USAGE();

            case ROUTINE_PRIVILEGES :
                return ROUTINE_PRIVILEGES();

            case ROUTINE_ROUTINE_USAGE :
                return ROUTINE_ROUTINE_USAGE();

            case ROUTINE_SEQUENCE_USAGE :
                return ROUTINE_SEQUENCE_USAGE();

            case ROUTINE_TABLE_USAGE :
                return ROUTINE_TABLE_USAGE();

            case ROUTINES :
                return ROUTINES();

            case SCHEMATA :
                return SCHEMATA();

            case SEQUENCES :
                return SEQUENCES();

            case SQL_FEATURES :
                return SQL_FEATURES();

            case SQL_IMPLEMENTATION_INFO :
                return SQL_IMPLEMENTATION_INFO();

            case SQL_PACKAGES :
                return SQL_PACKAGES();

            case SQL_PARTS :
                return SQL_PARTS();

            case SQL_SIZING :
                return SQL_SIZING();

            case SQL_SIZING_PROFILES :
                return SQL_SIZING_PROFILES();

            case TABLE_CONSTRAINTS :
                return TABLE_CONSTRAINTS();

            case TABLES :
                return TABLES();

            case TRANSLATIONS :
                return TRANSLATIONS();

            case TRIGGERED_UPDATE_COLUMNS :
                return TRIGGERED_UPDATE_COLUMNS();

            case TRIGGER_COLUMN_USAGE :
                return TRIGGER_COLUMN_USAGE();

            case TRIGGER_ROUTINE_USAGE :
                return TRIGGER_ROUTINE_USAGE();

            case TRIGGER_SEQUENCE_USAGE :
                return TRIGGER_SEQUENCE_USAGE();

            case TRIGGER_TABLE_USAGE :
                return TRIGGER_TABLE_USAGE();

            case TRIGGERS :
                return TRIGGERS();

            case USAGE_PRIVILEGES :
                return USAGE_PRIVILEGES();

            case USER_DEFINED_TYPES :
                return USER_DEFINED_TYPES();

            case VIEW_COLUMN_USAGE :
                return VIEW_COLUMN_USAGE();

            case VIEW_ROUTINE_USAGE :
                return VIEW_ROUTINE_USAGE();

            case VIEW_TABLE_USAGE :
                return VIEW_TABLE_USAGE();

            case VIEWS :
                return VIEWS();

            default :
                return super.generateTable(tableIndex);
        }
    }
1371761
def build_index(self, idx_name, _type='default'):
        ""
        indexes = {}
        has_non_string_values = False
        for key, item in self.data.items():
            if idx_name in item:
                value = item[idx_name]
                # A non-string index value switches it into a lazy one.
                if not isinstance(value, six.string_types):
                    has_non_string_values = True
                if value not in indexes:
                    indexes[value] = set([])
                indexes[value].add(key)
        self.indexes[idx_name] = indexes
        if self._meta.lazy_indexes or has_non_string_values:
            # Every index is lazy
            _type = 'lazy'
        self.index_defs[idx_name] = {'type': _type}
656074
def create_index(manager, prop, node_type='Node'):
    
    with manager.session as s:
        s.run('CREATE INDEX ON :{node_type}({prop})'.format(node_type=node_type, prop=prop))
778725
def _create_index(self):
        """"""
        if not self.index_exists:
            index_settings = {}
            headers = {'Content-Type': 'application/json', 'DB-Method': 'POST'}
            url = '/v2/exchange/db/{}/{}'.format(self.domain, self.data_type)
            r = self.tcex.session.post(url, json=index_settings, headers=headers)

            if not r.ok:
                error = r.text or r.reason
                self.tcex.handle_error(800, [r.status_code, error])
            self.tcex.log.debug(
                'creating index. status_code: {}, response: "{}".'.format(r.status_code, r.text)
            )
285179
def create_index(self, index):
    

    index._path = os.path.join(self.indexes_path, index._name)

    if whoosh.index.exists_in(index._path):
      _whoosh = whoosh.index.open_dir(index._path)
    elif not os.path.exists(index._path):
      os.makedirs(index._path)
      _whoosh = whoosh.index.create_in(index._path, index._schema)
    index._whoosh = _whoosh
550382
def create_index(self, columns, name=None, index_type="btree"):
        
        self._check_dropped()
        if not name:
            sig = "||".join(columns + [index_type])
            # This is a work-around for a bug in <=0.6.1 which would create
            # indexes based on hash() rather than a proper hash.
            key = abs(hash(sig))
            name = "ix_%s_%s" % (self.table.name, key)
            if name in self.indexes:
                return self.indexes[name]
            key = sha1(sig.encode("utf-8")).hexdigest()[:16]
            name = "ix_%s_%s" % (self.table.name, key)
        if name in self.indexes:
            return self.indexes[name]
        # self.db._acquire()
        columns = [self.table.c[col] for col in columns]
        idx = Index(name, *columns, postgresql_using=index_type)
        idx.create(self.engine)
        # finally:
        #    self.db._release()
        self.indexes[name] = idx
        return idx