Primary key without index in the table?

I'm just wondering if we can create the main key in a table on sql server without any index on it?

+6
source share
3 answers

Not. As part of the implementation, SQL Server supports the primary key using an index. You cannot stop it from doing this. Primary Key:

  • Ensures no duplicate key values
  • Allows identification / access to individual lines

SQL Server already has mechanisms that offer these functions — unique indexes, so it uses them to enforce constraints.

+10
source

In fact, indexing functions are moved in the same way by a book. It is impossible to go to a specific page or topic, unless the page number and their relation to the topics. This Paging (ordering) of rows is done physically using the clustered index in SQL Server. If there is no PC in the table, you can add a clustered index for each column (s) of the unique key. Since a table cannot have more than one clustered index, and all other non-clustered indexes depend on the clustered index for search / crawl, you cannot make a PK column without a clustered index.

0
source

You can create a table with a primary key that is not a clustered index by adding the keyword NONCLUSTERED after the word primary key .

-1
source

Source: https://habr.com/ru/post/924504/


All Articles