Clustered index, non-clustered index, the only index

https://zhidao.baidu.com/question/1573903009844889260.html

  Clustered index is not necessarily unique index .
The primary key is unique, at the same time creates a primary key, the field will create a unique index,  the only index in fact require that all data in the column specified must be different. Primary key a unique index difference:
1 a primary key table can have only one, while the unique index can be built more.
2 the primary key as a foreign key in another table.
3 is the primary key is not null, unique index can be null.
1, the clustered index
(1) first noted a misunderstanding, the primary key is not necessarily a clustered index, but in SQL SERVER, the case is not explicitly stated, the default will be the primary key is defined as the aggregate, and ORACLE in the default non-aggregated, because SQL SERVER the ROWID is not open for use.
(2) suitable for clustered index is required to find the range of the column, since the clustered index leaf node is stored in ordered rows, the query engine according WHERE given range, positioned directly to both ends of the leaf node , the this part of the data node list page out of the box according to the order;
(3) try to build a clustered index on the column value changes will not happen, otherwise it will bring non-clustered index ; maintenance
(4) as far as the establishment of a non-clustered index before build clustered index, otherwise it will lead to all on the table non-clustered index reconstruction;
(5) should be avoided clustered index based on the value monotonous row, otherwise it may cause competition IO, as well as unbalanced B-tree, resulting in the database systemFrequent maintenance balance of the B-tree. Clustered index column values in the table can be preferably evenly distributed .
2, a unique index
(1) a further point out errors, clustered index is not necessarily a unique index, because the SQL SERVER default is defined as the primary key clustered index, in fact, the index is unique and is not relevant whether the aggregate, can be clustered index unique index, or a non-unique index;
(2) the index is set to be unique, to find equivalence is very beneficial when found in the first qualifying record can stop searching, data is returned, but not unique We will have to continue to find the same, due to the need to ensure the uniqueness of each line will insert the data to check the repeatability;

Guess you like

Origin www.cnblogs.com/dusf/p/11033041.html