what rules does SQL Server use to determine which column/columns will the phantom clustered index be created on? [closed]

StackOverflow https://stackoverflow.com/questions/6800864

Pergunta

The Definitive Guide to Scaling out SQL Server 2005:

if you create a nonclustered index and don’t already have a clustered index, SQL Server creates a “phantom” clustered index because nonclustered indexes always point to clustered index keys.

  1. What rules does SQL Server use to determine which column/columns will the phantom clustered index be created on?

  2. If it is on the primary key of that table (quick guess), what rules does SQL Server use to determine which column/columns will the phantom clustered index be created on for a table without primary keys?

(question targeted at any version of SQL Server 2005 and beyond)

Foi útil?

Solução

When you define a primary key, SSMS will by default make that the clustered index. But if you specifically create a table without a clustered index, you are creating a heap table. SQL Server uses an internal value for referencing rows, but it is not any of your columns. The following may help:

On a Heap Table, what does a non-clustered index use as a pointer to a row?

http://msdn.microsoft.com/en-us/library/aa964133%28v=sql.90%29.aspx

http://www.mssqltips.com/tip.asp?tip=1254

Outras dicas

The quote you are providing is wrong. You might want to read a high quality book, such as a book by Kalen Delaney: http://www.sqlserverinternals.com/books.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top