oracle序列

来源:互联网 发布:知乎 唯一住房 编辑:程序博客网 时间:2024/05/12 19:14

/*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_table
(
TestID int primary key,
TestName varchar2(20) not null,
Tdescription varchar2(200) null
)

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

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

原创粉丝点击