Hopefully, I can get answers for each database server.
For an outline of how indexing works check out: How does database indexing work?
To create indexes following stuff can be used:
Creates an index on a table. Duplicate values are allowed:
CREATE INDEX index_name
ON table_name (column_name)
Creates a unique index on a table. Duplicate values are not allowed:
CREATE UNIQUE INDEX index_name ON table_name (column_name)
Clustered Index: CREATE CLUSTERED INDEX CL_ID ON SALES(ID);
CREATE NONCLUSTERED INDEX NONCI_PC ON SALES(ProductCode);
Refer: http://www.codeproject.com/Articles/190263/Indexes-in-MS-SQL-Server for details.
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()