Home  >  Article  >  Database  >  Oracle使用序列填充代理主键自增

Oracle使用序列填充代理主键自增

WBOY
WBOYOriginal
2016-06-07 17:00:381343browse

创建表tmp_tab,并将序列seqId使用于主键id新建序列:create sequence seqId start with 1 increment by 1;新建表空间:create t

创建表tmp_tab,,并将序列seqId使用于主键id

新建序列:create sequence seqId start with 1 increment by 1;

新建表空间:create table tmp_tab(id  integer constraint seq1 primary key,col1 varchar2(10),mod_date date default sysdate)

s

插入数据:insert  into tmp_tab(id ,  col1)values(seq1.nextval, ‘Hello’)

修改序列:

使用ALTER  SEQUENCE语句修改

不能修改序列的初始值

序列的最小值不能大于当前值

序列的最大值不能小于当前值

修改序列seq1,让其增量值为2

语句如下:

alter  sequence  seq1

increment  by  2;

删除序列:

drop sequence  seq1;s

linux

Statement:
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