3

When I use the below query to create index for a column in MS SQL Server

create index IX_indexname on tablename(columnname);

without mentioning it as clustered or non clustered index, what index will be created? Which is the default index?

Dinesh M
  • 1,026
  • 8
  • 23
  • 1
    [tag:sql] refers to the SQL Standard. Are you working with a *specific* RDBMS? If so,please [edit] and add a tag for your product. Then, consider that there's probably *documentation* for the product that will spell this out when you read about `create index` in there. – Damien_The_Unbeliever Mar 02 '17 at 07:33
  • 1
    Which DBMS are you talking about? –  Mar 02 '17 at 07:43

2 Answers2

3

Default would be non clustered.

You can refer to documentation when in doubt..

Below is the syntax from MSDN for create index statement

CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name

everything in Square brackets is optional,so you would be left with

create index index_name

MSDN again says

If CLUSTERED is not specified, a nonclustered index is created.

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
2

As you're referring to clustered indexes, I'm guessing this question refers to MS SQL Server. Unless you explicitly specify it to be clustered, an index would be non-clustered.

Mureinik
  • 297,002
  • 52
  • 306
  • 350