当前位置:数据库 > Oracle >>

Oracle创建序列及循环自增取值问题

Oracle创建序列及循环自增取值问题
 
用sys登陆Oracle
 
SQL> conn sys/root as sysdba;
 
创建sequence
 
SQL> create sequence test_seq maxvalue 9 increment by 2 start with 1 cache 2 cycle;
 
创建对应测试table
 
SQL> create table test_table(next number,curr number);
插入测试数据(循环执行10次)
 
SQL> insert into test_table(next,curr) values (test_seq.nextval,test_seq.currval);
 
取出数据:
 
SQL> select * from testseq1;
 
      NEXT       CURR
---------- ----------
         1          1
         3          3
         5          5
         7          7
         9          9
        11         11
        13         13
        15         15
        17         17
        19         19
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,