ORACLE中创建序列

2007-12-18

create    sequence    name
increment    by    x    //x为增长间隔
start    with      x    //x为初始值
maxvalue          x    //x为最大值
minvalue          x    //x为最小值
cycle                 //循环使用,到达最大值或者最小值时,从新建立对象
cache             x    //制定缓存序列值的个数

------------------------一个例子-----------------------
create    sequence    for_test   --序列名
increment    by    1      --每次增加1
start    with    1      --从1开始
nomaxvalue      --没有最大值
nocache         --没有缓存序列

----------------------------创建测试表------------------
create table Test
(
TestID int primary key,
TestName varchar2(20) not null,
Tdescription varchar2(200) null
)

-----------------------------使用序列-------------------
insert into Test
values(for_test.nextval,'序列测试','这是一个序列使用的例子')

--------------------序列使用结果查询-----------------
select * from test

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注