如何在查询中创建索引? [英] How to create index in query?

查看:148
本文介绍了如何在查询中创建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

您能否告诉我如何在查询中创建聚簇索引和非聚簇索引.创建后如何删除它.



在此先感谢

Hi Friends,

Could u plz tell me how to create clustered index and non-clustered index in query. How to remove that after creating.



Thanks in Advance

推荐答案

看了 http://technet.microsoft.com/zh-CN/library/ms189280.aspx [ ^ ]和 http://www.sql-server-performance.com/2004/index-data-structures/ [

在运行查询时,您不会真正创建索引.这将带来巨大的性能问题,尤其是在您的表很大的情况下.

(这可能是您在存储过程中创建的#temp表上的例外)

您的表应该使用索引进行调整,以使查询可以高效地针对它们运行.

通常,每个表都应具有聚集索引(
http://www.sql-server- performance.com/2007/clustered-indexes/ [ ^ ])

然后,它们应具有所需的索引数,以便查询运行良好,但记录的添加\删除操作不会受到不利影响

阅读有关SQL查询调整的信息.
You wouldn''t really create indexes as queries are run. This would have massive performance issues, particular if your table is large.

(an exception to this might be on #temp tables you''ve created in stored proceudre)

Your tables should be tuned with indexes so that queries will run effeciently against them.

As a general rule, every table should have a clustered index (http://www.sql-server-performance.com/2007/clustered-indexes/[^])

They should then have as many indexes as required so that queries run well, but record additions\deletions aren''t adversely affected

Read up on SQL query tuning.


看看那里 [ ^ ]了解有关群集的信息以及无丛集的设计指南及其结构.
要删除索引,您可以使用 DROP INDEX [那里-[禁用索引和约束的准则] [
Take a look there[^] to know about Clustered and No-clustered design guidelines and its structure.
To remove index you can use DROP INDEX[^]
The DROP INDEX statement does not apply to indexes created by defining PRIMARY KEY or UNIQUE constraints. To remove the constraint and corresponding index, use ALTER TABLE with the DROP CONSTRAINT clause.
so Its better to read some guidelines for Disabling Index. take a look there-[Guidelines for Disabling Indexes and Constraints][^]


这篇关于如何在查询中创建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆