sys.sequences (Transact-SQL)sys.sequences (Transact-SQL)

适用对象:是SQL Server 是Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

数据库中的每个序列对象各占一行。Contains a row for each sequence object in a database.

列名Column name 数据类型Data type 描述Description
<继承列 ><inherited columns> 继承中的所有列sys.objectsInherits all columns from sys.objects.
start_valuestart_value sql_variant 不为 NULLsql_variant NOT NULL 序列对象的起始值。The starting value for the sequence object. 如果使用 ALTER SEQUENCE 重新启动序列对象,它将以此值重新启动。If the sequence object is restarted by using ALTER SEQUENCE it will restart at this value. 当序列对象周期它继续到minimum_valuemaximum_value,而不start_valueWhen the sequence object cycles it proceeds to the minimum_value or maximum_value, not the start_value.
incrementincrement sql_variant 不为 NULLsql_variant NOT NULL 用于在每个生成值后使序列对象递增的值。The value that is used to increment the sequence object after each generated value.
minimum_valueminimum_value sql_variant NULLsql_variant NULL 序列对象可以生成的最小值。The minimum value that can be generated by the sequence object. 在达到此值后,序列对象将在尝试生成多个值时返回错误,或在指定 CYCLE 选项时重新启动。After this value is reached, the sequence object will either return an error when trying to generate more values or restart if the CYCLE option is specified. 如果尚未指定任何 MINVALUE,此列将返回序列生成器的数据类型所支持的最小值。If no MINVALUE has been specified, this column returns the minimum value supported by the sequence generator's data type.
maximum_valuemaximum_value sql_variant NULLsql_variant NULL 序列对象可以生成的最大值。The maximum value that can be generated by the sequence object. 在达到此值后,序列对象将在尝试生成多个值时开始返回错误,或在指定 CYCLE 选项时重新启动。After this value is reached the sequence object will either start returning an error when trying to generate more values or restart if the CYCLE option is specified. 如果未指定任何 MAXVALUE,此列将返回序列对象的数据类型所支持的最大值。If no MAXVALUE has been specified this column returns the maximum value supported by the sequence object's data type.
is_cyclingis_cycling 位 NOT NULLbit NOT NULL 如果为序列对象指定 NO CYCLE,则返回 0;如果指定 CYCLE,则返回 1。Returns 0 if NO CYCLE has been specified for the sequence object and 1 if CYCLE has been specified.
is_cachedis_cached 位 NOT NULLbit NOT NULL 如果为序列对象指定 NO CACHE,则返回 0;如果指定 CACHE,则返回 1。Returns 0 if NO CACHE has been specified for the sequence object and 1 if CACHE has been specified.
cache_sizecache_size int NULLint NULL 返回序列对象的指定缓存大小。Returns the specified cache size for the sequence object. 如果创建序列时使用了 NO CACHE 选项或者指定了 CACHE 但未指定缓存大小,此列将包含 NULL。This column contains NULL if the sequence was created with the NO CACHE option or if CACHE was specified without specifying a cache size. 如果缓存大小指定的值大于序列对象可以返回的值的最大数量,仍会显示该无法获得的缓存大小。If the value specified by the cache size is larger than the maximum number of values that can be returned by the sequence object, that unobtainable cache size is still displayed.
system_type_idsystem_type_id tinyint NOT NULLtinyint NOT NULL 序列对象的数据类型的系统类型的 ID。ID of the system type for sequence object's data type.
user_type_iduser_type_id int NOT NULLint NOT NULL 用作用户定义的序列对象的数据类型的 ID。ID of the data type for the sequence object as defined by the user.
精度precision tinyint NOT NULLtinyint NOT NULL 数据类型的最大精度。Max precision of the data type.
scalescale tinyint NOT NULLtinyint NOT NULL 数据类型的最大小数位数。Max scale of the type. 小数位数与精度一起返回,以便为用户提供完整的元数据。Scale is returned together with precision to give users complete metadata. 由于序列对象只允许使用整数类型,因此其小数位数始终为 0。Scale is always 0 for sequence objects because only integer types are allowed.
current_valuecurrent_value sql_variant 不为 NULLsql_variant NOT NULL 强制的最后一个值。The last value obligated. 从最近执行 NEXT VALUE FOR 函数或执行的最后一个值返回的值,即sp_sequence_get_range过程。That is, the value returned from the most recent execution of the NEXT VALUE FOR function or the last value from executing the sp_sequence_get_range procedure. 如果从未使用过该序列,则返回 START WITH 值。Returns the START WITH value if the sequence has never been used.
is_exhaustedis_exhausted 位 NOT NULLbit NOT NULL 0 表示可从序列中生成多个值。0 indicates that more values can be generated from the sequence. 1 表示序列对象已达到 MAXVALUE 参数,该序列未设置为 CYCLE。1 indicates that the sequence object has reached the MAXVALUE parameter and the sequence is not set to CYCLE. 使用 ALTER SEQUENCE 重新启动序列之前,NEXT VALUE FOR 函数将返回错误。The NEXT VALUE FOR function returns an error until the sequence is restarted by using ALTER SEQUENCE.
last_used_valuelast_used_value sql_variant NULLsql_variant NULL 返回生成的最后一个值Next Value For函数。Returns the last value generated by the Next Value For function. 适用于 SQL Server 2017 及更高版本。Applies to SQL Server 2017 and later.

权限Permissions

SQL Server 2005 (9.x)SQL Server 2005 (9.x) 及更高版本中,目录视图中仅显示用户拥有的安全对象的元数据,或用户对其拥有某些权限的安全对象的元数据。In SQL Server 2005 (9.x)SQL Server 2005 (9.x) and later versions, the visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. 有关详细信息,请参阅 Metadata Visibility ConfigurationFor more information, see Metadata Visibility Configuration.

请参阅See Also

序列号 Sequence Numbers
CREATE SEQUENCE (Transact-SQL) CREATE SEQUENCE (Transact-SQL)
ALTER SEQUENCE (Transact-SQL) ALTER SEQUENCE (Transact-SQL)
DROP SEQUENCE (Transact-SQL) DROP SEQUENCE (Transact-SQL)
NEXT VALUE FOR (Transact-SQL) NEXT VALUE FOR (Transact-SQL)
sp_sequence_get_range (Transact-SQL)sp_sequence_get_range (Transact-SQL)