MySQL 一级索引和二级索引到底有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20824686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is difference between primary index and secondary index exactly?
提问by user3099630
Can any one tell me what's the exact difference between Primary index & Secondary index? What are the different indexes that comes under category of primary & secondary index? And what's advantages of using primary index over secondary index & vice versa?
谁能告诉我一级索引和二级索引之间的确切区别是什么?一级和二级索引类别下有哪些不同的索引?与二级索引相比,使用一级索引有什么优势,反之亦然?
回答by Kumod Singh
Primary index:
主要指标:
A primary index is an index on a set of fields that includes the unique primary key for the field and is guaranteed not to contain duplicates. Also Called a Clustered index. eg. Employee ID can be Example of it.
主索引是一组字段上的索引,其中包含该字段的唯一主键并保证不包含重复项。也称为聚集索引。例如。员工 ID 可以是它的示例。
Secondary index:
二级指标:
A Secondary index is an index that is not a primary index and may have duplicates. eg. Employee name can be example of it. Because Employee name can have similar values.
二级索引是一个不是主索引并且可能有重复的索引。例如。员工姓名就是一个例子。因为 Employee name 可以具有相似的值。
The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
主索引包含表的关键字段。当表被激活时,主索引会自动在数据库中创建。如果一个大表被频繁访问以至于无法应用主索引排序,您应该为该表创建二级索引。
The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
表上的索引具有三个字符的索引 ID。'0' 为主索引保留。客户可以在 SAP 表上创建自己的索引;他们的 ID 必须以 Y 或 Z 开头。