SQL Server primary key solutions NEWID (), increment ID

Reference official website:  https://docs.microsoft.com/zh-cn/previous-versions/sql/sql-server-2005/ms189826(v=sql.90)

 

Primary key table in SQL Server has increment Id, and GUID.

  1. increment Id

    Advantages: small space index, the index continuously. In large amounts of data insertion when there is a particularly large performance advantage.

    Disadvantages: poor portability, when the data migration.

  2. GUID

    Pros: When data migration easy.

    Disadvantages: large index space, because the GUID of randomness, when inserted in the data will lead to contention on the index page.

 

SQL SERVER 2005 added a new NEWSEQUENTIALID (), which is built-in functions can not be used with SELECT 

 

- Table unbridled created newsequentialid default ()
the Create the Table #t
(
the above mentioned id uniqueidentifier not null default newsequentialid ()
, name VARCHAR (100)
)
Go

- inserting the data table 100, and to specify the column name
INSERT INTO #t (name) values ( 'A')
Go 100

select * from #t

 

 

 

 

Guess you like

Origin www.cnblogs.com/xiaohuizhenyoucai/p/11413207.html