How do I index a database column How do I index a database column database database

How do I index a database column


The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL:

CREATE INDEX [index name] ON [table name] ( [column name] )


Sql Server 2005 gives you the ability to specify a covering index. This is an index that includes data from other columns at the leaf level, so you don't have to go back to the table to get columns that aren't included in the index keys.

create nonclustered index my_idx on my_table (my_col1 asc, my_col2 asc) include (my_col3);

This is invaluable for a query that has my_col3 in the select list, and my_col1 and my_col2 in the where clause.


For python pytables, indexes don't have names and they are bound to single columns:

tables.columns.column_name.createIndex()