Home > Database > Mysql Tutorial > SQL Server 2012 SEQUENCE 对象

SQL Server 2012 SEQUENCE 对象

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:59:11
Original
899 people have browsed it

Oracle中有sequence的功能,SQL Server类似的功能使用Identity列实现,但是有很大的局限性。在2012中,微软终于增加了 sequence 对象,功能和性能都有了很大的提高。 我们可以在SSMS中创建也可以使用SQL Server脚本创建序列对象: 使用SQL创建序列对象: IF E

Oracle中有sequence的功能,SQL Server类似的功能使用Identity列实现,但是有很大的局限性。在2012中,微软终于增加了 sequence 对象,功能和性能都有了很大的提高。

我们可以在SSMS中创建也可以使用SQL Server脚本创建序列对象:





使用SQL创建序列对象:

IF EXISTS(SELECT*FROMsys.sequencesWHEREname=N'TestSeq')

                DROP SEQUENCETestSeq;

GO



--创建序列对象

CREATE SEQUENCETestSeqAStinyint

                START WITH1

                INCREMENT BY1;

GO



--创建表

CREATE TABLE TEST

(ID tinyint,  Namevarchar(150))



--产生序列号码并插入表中

INSERT INTO TEST

(ID,Name)

VALUES

(NEXT VALUE FOR TestSeq,'allen')



INSERT INTO TEST

(ID,Name)

VALUES

(NEXT VALUE FOR TestSeq,'kevin')



SELECT * FROM TEST



--产生序列可以重复使用,下面的例子当序列号码超过255后
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template