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,序列,创建)