非聚集索引中的唯一键约束

编程入门 行业动态 更新时间:2024-10-09 16:32:13
本文介绍了非聚集索引中的唯一键约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 是否必须在列中使用唯一值来创建表中列的非聚集索引? 要创建非聚集索引的列不是表的主键。 请提供一些示例或链接可能会有很大帮助。 谢谢

Hi All, Is it mandatory to have unique values in column to create non clustered index with the column in the table? The column over which the non clustered index is to be created is not the primary key of the table. Please provide some examples or links that may help a lot. Thanks

推荐答案

黑人大师 不,它不需要对非聚集索引具有唯一约束。如果您是一家汽车公司,您可能会有一个简单的汇总表,其中包含您所制造的所有汽车。 Car_History VIN编号 颜色 型号 生成日期 发售日期 Car_History表可能在VIN编号上有一个主键/索引。这将是一个独特的约束。但他们可能还会在制造/销售汽车的两个日期列中有一个索引。这些列将具有重复的条目,因为它易于生产并且每天销售多辆汽车。在这种情况下,将这些列编入索引是有意义的。然后可以在不同的时间段运行摘要报告,以帮助理解产品的销售周期。 在这种情况下,索引中不可能有唯一值因为日期可能会重复! 我希望这会有所帮助! Hogan Master Black No, its not required to have a unique constraint on a non-clustered index. If you were an automotive company, you might have a simple summary table with all of the cars you ever made. Car_History VIN Number Color Model Date Produced Date Sold The Car_History table would likely have a primary key/index on VIN Number. That would be a unique constraint. But they would probably also have an index on the two date columns for when cars were made/sold. Those columns would have duplicate entries as its easy to produce and sell more than one car each day. In this instance, it would make sense to index these columns. Then summary reports could be run on different time periods to help understand the sales cycle of products. In this instance, it would be impossible to have unique values in the index as the dates would surly be duplicated! I hope this helps! Hogan

更多推荐

非聚集索引中的唯一键约束

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

发布评论

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

>www.elefans.com

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