SQL SERVER 2012使用sequence

从之前Oracle转过来,现在看sql server中对于id的实现竟然用guid这种方式。为啥不像在Oracle中一样使用Sequence并行获取序列号呢?今天看MSDN才发现在sql server 2012版本中才首次引入sequence。

MSDN链接

以下提供一个样例如何创建和使用sequence:

CREATE SEQUENCE test_sequence          
                 START WITH 1
                 INCREMENT BY 1
                 MINVALUE 1
                 MAXVALUE 2147483647
                 
select * from sys.sequences

SELECT cache_size, current_value 
FROM sys.sequences
WHERE name = 'test_sequence' ;

select next value for test_sequence 

posted on 2015-05-22 18:04  camash  阅读(535)  评论(0编辑  收藏  举报

导航