Oracle Sequences Oracle Sequences oracle oracle

Oracle Sequences


It will just return 201, as the sequence has no idea what the numbers are used for.

Note: It may return, say, 220 if you have specified that the sequence has to cache values for some session (see the Oracle manual about CREATE SEQUENCE for more details)


Sequences just provide a way to "select" numbers that auto increment.

You will get 201 because they don't check anything, they just store the last value retrieved and when you query it again, it will return the next value in the sequence.


It will return 201.

You could also use nextval from JDBC, and then use that value to do the insert:

Statement st = conn.createStatement();ResultSet rs = st.executeQuery("select seq.nextval from dual");rs.next();int yourId = rs.getInt(1);// then use yourId to do the insert

This way you can insert using a number, and also keep the sequence the way it should be.