--- title: "CREATE INDEX (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: 11/12/2019 ms.prod: sql ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw" ms.reviewer: "" ms.technology: t-sql ms.topic: "language-reference" f1_keywords: - "CREATE INDEX" - "INDEX" - "INDEX_TSQL" - "CREATE_INDEX_TSQL" dev_langs: - "TSQL" helpviewer_keywords: - "CREATE XML INDEX statement" - "PRIMARY XML INDEX statement" - "indexes [SQL Server], creating" - "online index operations" - "index keys [SQL Server]" - "PROPERTY INDEX statement" - "computed columns, index creation" - "clustered indexes, creating" - "indexed views [SQL Server], index creation" - "partitioned indexes [SQL Server], creating" - "VALUE INDEX statement" - "index creation [SQL Server], CREATE INDEX statement" - "DROP_EXISTING clause" - "row locks [SQL Server]" - "composite indexes" - "MAXDOP index option, CREATE INDEX statement" - "filtered indexes [SQL Server], creating" - "PATH INDEX statement" - "locking [SQL Server], indexes" - "unique indexes, creating" - "primary indexes [SQL Server]" - "CREATE PRIMARY XML INDEX statement" - "SET statement, index creation" - "index options [SQL Server]" - "included columns" - "ONLINE option" - "nonclustered indexes [SQL Server], creating" - "CREATE INDEX statement" - "IGNORE_DUP_KEY option" - "deterministic functions" - "keys [SQL Server], index" - "SECONDARY XML INDEX statement" - "page locks [SQL Server]" - "secondary indexes [SQL Server]" - "XML indexes [SQL Server], creating" ms.assetid: d2297805-412b-47b5-aeeb-53388349a5b9 author: pmasl ms.author: carlrab monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current" --- # CREATE INDEX (Transact-SQL) [!INCLUDE[tsql-appliesto-ss2008-all-md](../../includes/tsql-appliesto-ss2008-all-md.md)] Creates a relational index on a table or view. Also called a rowstore index because it is either a clustered or nonclustered B-tree index. You can create a rowstore index before there is data in the table. Use a rowstore index to improve query performance, especially when the queries select from specific columns or require values to be sorted in a particular order. > [!NOTE] > [!INCLUDE[ssSDW](../../includes/sssdw-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)] currently do not support Unique constraints. Any examples referencing Unique Constraints are only applicable to [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] and [!INCLUDE[ssSDS](../../includes/sssds-md.md)]. > [!TIP] > For information on index design guidelines, refer to the [SQL Server Index Design Guide](../../relational-databases/sql-server-index-design-guide.md). **Simple examples:** ```sql -- Create a nonclustered index on a table or view CREATE INDEX i1 ON t1 (col1); -- Create a clustered index on a table and use a 3-part name for the table CREATE CLUSTERED INDEX i1 ON d1.s1.t1 (col1); -- Syntax for SQL Server and Azure SQL Database -- Create a nonclustered index with a unique constraint -- on 3 columns and specify the sort order for each column CREATE UNIQUE INDEX i1 ON t1 (col1 DESC, col2 ASC, col3 DESC); ``` **Key scenario:** Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] and [!INCLUDE[ssSDS](../../includes/sssds-md.md)], use a nonclustered index on a columnstore index to improve data warehousing query performance. For more information, see [Columnstore Indexes - Data Warehouse](../../relational-databases/indexes/columnstore-indexes-data-warehouse.md). For additional types of indexes, see: - [CREATE XML INDEX](../../t-sql/statements/create-xml-index-transact-sql.md) - [CREATE SPATIAL INDEX](../../t-sql/statements/create-spatial-index-transact-sql.md) - [CREATE COLUMNSTORE INDEX](../../t-sql/statements/create-columnstore-index-transact-sql.md) ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ### Syntax for SQL Server and Azure SQL Database ``` CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name ON ( column [ ASC | DESC ] [ ,...n ] ) [ INCLUDE ( column_name [ ,...n ] ) ] [ WHERE ] [ WITH ( [ ,...n ] ) ] [ ON { partition_scheme_name ( column_name ) | filegroup_name | default } ] [ FILESTREAM_ON { filestream_filegroup_name | partition_scheme_name | "NULL" } ] [ ; ] ::= { database_name.schema_name.table_or_view_name | schema_name.table_or_view_name | table_or_view_name } ::= { PAD_INDEX = { ON | OFF } | FILLFACTOR = fillfactor | SORT_IN_TEMPDB = { ON | OFF } | IGNORE_DUP_KEY = { ON | OFF } | STATISTICS_NORECOMPUTE = { ON | OFF } | STATISTICS_INCREMENTAL = { ON | OFF } | DROP_EXISTING = { ON | OFF } | ONLINE = { ON | OFF } | RESUMABLE = {ON | OF } | MAX_DURATION =