How to create a sequence which start with 1 and next value will be 0 and then next value is 1 and then 0 .. and so on ... is this possible ?

SQL> CREATE SEQUENCE TEST_SEQ_A
           START WITH 1
           MINVALUE 0
           MAXVALUE 1
           INCREMENT BY -1
           NOCACHE
           ORDER
           CYCLE ;

SQL> Insert into test(seq) values(TEST_SEQ_A.nextval);
SQL> Select *from test;

Output:
1
0
1
0
1
0....

Leave a Comment

close button