[Oracle] Sequence object usage, oraclesequence object
**************************************** ********************************* *** Original article: blog.csdn.net/clark_xu Xu changliang's column**************************************** ********************************
Sequence: oracle can generate primary keys through sequences.
1. Create a sequence
Create table Foo (
Foo_id number (11 ),
Foo_value varchar2 (50 ),
Constraint FOO_PK primary key (foo_id)
)
Create sequence DDL
Create sequence name
[Start with value (10000)]
[Increment by value]
Delete sequence DDL
Drop sequence name
2. view the sequence
Obtain the current sequence value through the pseudo-column currval
Use the pseudo column nextval to obtain the next value of the sequence value.
Select seq_foo.nextval from dual;
Select seq_foo.currval from dual;
3. Use sequence as the primary key
Insert into foo (foo_id, foo_value) values (seq. foo. nextval, 'clark ');