sequence : Is an object provided by Oracle that produces a unique numeric value, primarily for use with a single primary key of a table.
To Create a sequence :
Create sequence seq_name//naming
Start with 1//initial value
Increment by 1//increment value
MinValue 1//minimum value, default, system default
MaxValue 999999999999999999//maximum value, default, system default value
nocache//cache Cache is not cached is a one-time system to read how many values put into the current session of the sequence pool for use to improve efficiency, but easy to jump
cycle//loop nocycle does not cycle when an object reaches the Extremum, does the iteration begin Again
The order//guarantees the value of the read sequence, consistent with the order of the connection session, before the value is first connected. Default Value Noorder
;
Use sequence:
Select sequence name. Currval from dual view current sequence values
Select sequence name. Nextval from dual View the number of the next sequence, which automatically adds an increment to the current sequence
Precautions, first use, first nextval otherwise error "appears ORA-08002: sequence Xxxxxxx.currval has not yet been defined in this process. "
To modify a sequence:
alter sequence seq_name MaxValue 9999999;
Note: You cannot change the maximum value to 1000 if the change is to conform to logic, such as when the next number of the sequence is 10000.
To delete a sequence:
drop sequence seq_name
Comprehensive case
MySQL table primary key auto-increment effect with Oracle Trigger
Create a Trigger
Create or Replace trigger trg_t_name//define triggers
Before insert on T_name for each row//new record operation
Begin
Select Seq_name.nextval into:new.id from dual;//application sequence
End
Reference : http://docs.oracle.com/cd/E11882_01/server.112/e41084/toc.htm
Oracle sequence Sequence