如何在查询中创建索引?

编程入门 行业动态 更新时间:2024-10-26 06:33:13
本文介绍了如何在查询中创建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

朋友, 您能否告诉我如何在查询中创建聚簇索引和非聚簇索引.创建后如何删除它. 在此先感谢

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

推荐答案

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

在运行查询时,您不会真正创建索引.这将带来巨大的性能问题,尤其是在您的表很大的情况下. (这可能是您在存储过程中创建的#temp表上的例外) 您的表应该使用索引进行调整,以使查询可以高效地针对它们运行. 通常,每个表都应具有聚集索引( www.sql-server- performance/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 (www.sql-server-performance/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 [ ^ ] DROP INDEX语句不适用于通过定义PRIMARY KEY或UNIQUE约束创建的索引.要删除约束和相应的索引,请在DROP CONSTRAINT子句中使用ALTER TABLE. 因此最好阅读一些有关禁用索引的准则.看一下那里-[禁用索引和约束的准则] [ ^ ] 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][^]

更多推荐

如何在查询中创建索引?

本文发布于:2023-10-23 18:49:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!