PL/SQL – sequences

Create and use sequence:

CREATE SEQUENCE hr.myseq
INCREMENT BY 1
START WITH -100
MAXVALUE 200
MINVALUE -200
CYCLE
CACHE 100; -- how many next values should be prepared and ready to use

select hr.myseq.nextval from dual; -- selects next unique value
select hr.myseq.currval from dual; -- selects last produced value, but only in current session!

Sequence can be altered, but one property cannot be changed in alter command – it is starting value.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s