alter_sequence 中文man页面

系统
ALTER SEQUENCE 命令修改一个现有的序列发生器的参数。 任何没有明确在 ALTER SEQUENCE 命令里声明的参数都将保留原先的设置。

NAME

ALTER SEQUENCE - 更改一个序列生成器的定义

SYNOPSIS

ALTER SEQUENCE name [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
  

DESCRIPTION 描述

ALTER SEQUENCE 命令修改一个现有的序列发生器的参数。 任何没有明确在 ALTER SEQUENCE 命令里声明的参数都将保留原先的设置。  

PARAMETERS 参数

name

 一个要修改的序列的名字(可以有模式修饰)。
increment
INCREMENT BY increment 子句是可选的。一个正数会让序列成为递增序列,负数则成为递减序列。 如果没有声明,将沿用原来的递增值。
minvalue
NO MINVALUE

 可选的子句 MINVALUE minvalue  决定一个序列可以生成的最小的值。如果声明了 NO MINVALUE,将使用缺省值, 对于递增和递减的序列分别是 1 和 -2^63-1。如果没有声明任何选项,则沿用当前的最小值。
maxvalue
NO MAXVALUE

 可选的子句 MAXVALUE maxvalue 决定序列的***值。如果声明了 NO MAXVALUE,则使用缺省值,对于递增和递减的序列分别是 2^63-1 和 -1。如果两个选项都没有声明, 则沿用当前的***值。
start

 可选的 RESTART WITH start 子句允许序列可以在任何地方开始。
cache
CACHE cache 选项打开序列号预分配并存储在内存缓冲的功能。最小值是 1 (也就是每次只能生成一个数值,没有缓冲)。 如果没有声明,将沿用旧的缓冲值。
CYCLE

 可选的键字 CYCLE 可以用于允许序列在达到递增序列的 maxvalue 或者递减序列的 minvalue的时候重叠使用。 如果达到了极限,那么生成的下一个数字将分别是 minvaluemaxvalue
NO CYCLE

 如果声明了可选键字 NO CYCLE,任何在序列达到其***极限后对 nextval 的调用都将返回错误。 如果既未声明 CYCLE 也未声明 NO CYCLE, 那么将沿用原有的循环行为。

EXAMPLES 例子


 从 105 开始重新开始一个叫 serial 的序列:

ALTER SEQUENCE serial RESTART WITH 105;

NOTES 注意


 为了避免并发的事务从同一个序列获取数值的时候被阻塞住,ALTER SEQUENCE 操作从来不会回滚; 修改马上生效并且不能恢复。

ALTER SEQUENCE 将不会立即影响后端的 nextval 结果,除了当前的之外, 因为它又已经缓冲了的序列号。它们只有再使用光所有已经缓冲的数值之后才能意识到改变了的序列参数。当前后端将立即被影响。  

#p#

NAME

ALTER SEQUENCE - alter the definition of a sequence generator

SYNOPSIS

ALTER SEQUENCE name [ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
  

DESCRIPTION

ALTER SEQUENCE changes the parameters of an existing sequence generator. Any parameter not specifically set in the ALTER SEQUENCE command retains its prior setting.  

PARAMETERS

name
The name (optionally schema-qualified) of a sequence to be altered.
increment
The clause INCREMENT BY increment is optional. A positive value will make an ascending sequence, a negative one a descending sequence. If unspecified, the old increment value will be maintained.
minvalue
NO MINVALUE
The optional clause MINVALUE minvalue determines the minimum value a sequence can generate. If NO MINVALUE is specified, the defaults of 1 and -263-1 for ascending and descending sequences, respectively, will be used. If neither option is specified, the current minimum value will be maintained.
maxvalue
NO MAXVALUE
The optional clause MAXVALUE maxvalue determines the maximum value for the sequence. If NO MAXVALUE is specified, the defaults are 263-1 and -1 for ascending and descending sequences, respectively, will be used. If neither option is specified, the current maximum value will be maintained.
start
The optional clause RESTART WITH start changes the current value of the sequence.
cache
The clause CACHE cache enables sequence numbers to be preallocated and stored in memory for faster access. The minimum value is 1 (only one value can be generated at a time, i.e., no cache). If unspecified, the old cache value will be maintained.
CYCLE
The optional CYCLE key word may be used to enable the sequence to wrap around when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively. If the limit is reached, the next number generated will be the minvalue or maxvalue, respectively.
NO CYCLE
If the optional NO CYCLE key word is specified, any calls to nextval after the sequence has reached its maximum value will return an error. If neither CYCLE or NO CYCLE are specified, the old cycle behaviour will be maintained.

EXAMPLES

Restart a sequence called serial, at 105:

ALTER SEQUENCE serial RESTART WITH 105;

NOTES

To avoid blocking of concurrent transactions that obtain numbers from the same sequence, ALTER SEQUENCE is never rolled back; the changes take effect immediately and are not reversible.

ALTER SEQUENCE will not immediately affect nextval results in backends, other than the current one, that have preallocated (cached) sequence values. They will use up all cached values prior to noticing the changed sequence parameters. The current backend will be affected immediately.  

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 09:02:10

ALTER AGGRE中文man

2011-08-24 13:26:19

CREATE SEQU中文man

2011-08-24 09:14:47

alter_conve中文man

2011-08-24 09:51:53

alter_user中文man

2011-08-24 09:45:14

alter_table中文man

2011-08-24 09:29:18

alter_group中文man

2011-08-24 09:32:13

alter_langu中文man

2011-08-24 09:39:10

alter_schem中文man

2011-08-24 09:26:14

alter_funct中文man

2011-08-24 09:22:30

alter_domai中文man

2011-08-24 09:48:46

alter_trigg中文man

2011-08-24 09:18:45

alter_datab中文man

2011-08-24 09:36:00

alter_opera中文man

2011-08-24 14:46:42

drop_sequen中文man

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man
点赞
收藏

51CTO技术栈公众号