PostgreSQL之序列

2016/11/03 PostgreSQL 共 299 字,约 1 分钟

参考

createsequence

创建序列

create sequence  序列名 increment by n    --步长
                 start with n             --开始的值
                 maxvalue n | nomaxvalue  --最大的值
                 minvalue n | nominvalue  --最小的值
                 cycle      | nocycle     --是否循环
                 cache n    | nocache     --缓存n个

使用方法

select currval('序列名')
select nextval('序列名')

删除序列

drop sequence序列名

与oracle区别

oracle版  :        
    select   序列名.nextval from dual;

postgres版:      
    select nextval('序列名');

文档信息

Search

    Table of Contents