开发者

Sql Server 2005 novice query

I am very beginner in SQL Server 2005 and I am learning it from online tutorial, here is some of my question:

1: What is the difference between Select * from XYZ and Select ALL * from XYZ.

2: The purpose of Clustered index is like to make the search easier by physically sorting the table [as far as I kknow :-)]. Let say if have primary column on a table than is it good to create a clustered index on the table? because we have already a column which is sorted.

3: Why we can create 1 Clustered Index + 249 Nonclustered Index = 250 Index on a table? I understand the 开发者_Python百科requirement of 1 clustered index. But why 249?? Why not more than 249?


  1. No difference SELECT ALL is the default as opposed to SELECT DISTINCT

  2. Opinion varies. For performance reasons Clustered indexes should ideally be small, stable, unique, and monotonically increasing. Primary keys should also be stable and unique so there is an obvious fit there. However clustered indexes are well suited for range queries. Looking up individual records by PK can perform well if the PK is nonclustered so some authors suggest not "wasting" the clustered index on the PK.

  3. In SQL Server 2008 you can create up to 999 NCIs on a table. I can't imagine ever doing so but I think the limit was raised as potentially with "filtered indexes" there might be a viable case for this many. Indexes add a cost to data modification operations though as the changes need to be propagated in multiple places so I would imagine it would only be largely read only (e.g. reporting) databases that ever achieve even double figures of non clustered non filtered indexes.


For 3:

Everytime when you insert/delete record in the table ALL indexes must be updated. If you will have too many indexes it takes too long time.

If your table have more then 5-6 indexes I think you need take the time and check yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜