Change oracle Quence

Asked

Viewed 4,381 times

-1

How do I update the Sequence value?

Situation: I will create a Quence but it may be that this table is registered or not. Then how do I generate Quence 0 or then with value from which there is already record?

create Sequence S_SEG_EXE;

1 answer

2

You can use the ALTER SEQUENCE:

ALTER SEQUENCE S_SEG_EXE INCREMENT BY 100;

In the above example, the current value of the Quence increased by 100. The value may also be negative if you want to reduce the value.

  • but what syntax I can use in calling the value 100 if I don’t know what the current value

  • Don’t know how to get the value of a quence? SELECT S_SEG_EXE.NEXTVAL FROM DUAL

  • would that be the case? ALTER SEQUENCE S_SEG_EXE INCREMENT BY SELECT S_SEG_EXE.NEXTVAL FROM DUAL

  • NEXTVAL does not bring the next value? To get the current value, I think it is best to use CURRVAL: https://docs.oracle.com/cd/B28359_01/server.111/b28310/views002.htm#i1007824

  • If you create it new, you can set the initial value with START WITH 0 if you want to start at zero. Now to switch to the value you want, use the alter sequence

  • Yes, @hkotsubo, CURRVAL would be better: SELECT S_SEG_EXE.CURRVALFROM DUAL

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.