Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Sequences tips


Oracle Database Tips by Donald Burleson
 

Proper Use of Oracle Sequences

BEGIN
select
   INSTANCE_NUMBER INTO INST_ID
FROM
   V$INSTANCE;
select
   EMP_ID_SEQ.NEXTVAL INTO SEQ_NUM
FROM
   DUAL;
INST_SEQ_ID:=(INST_ID-1)*100000 + SEQ_NUM;
:NEW.EMP_ID:=INST_SEQ_ID;
END;.


Generally, sequences can be cached with cache values as high as 200 in RAC. This is much higher than for a regular Oracle instance. If there is insufficient caching, then contention can result which will show up as an increase in service times. If there are performance problems due to sequences, then examine the row cache locks statistics in the v$system_eventview to determine whether the problem is due to the use of Oracle sequences.

Use Oracle sequences to generate unique numbers and set the CACHE parameter to high value, if needed.

Administration of Sequences

Sequences are special database objects that provide numbers in sequence for input to a table. They are useful for providing generated primary key values and for input of number type columns such as purchase order, employee number, sample number, and sales order number, where the input must be unique and in some form of numerical sequence.

Creation of Sequences

Sequences are created by use of the CREATE SEQUENCE command.

where:

sequence_name. The name you want the sequence to have. This may include the user name if created from an account with DBA privilege.

n. An integer, positive or negative.

INCREMENT BY. Tells the system how to increment the sequence. If it is positive, the values are ascending; if it is negative, the values are descending.

START WITH. Tells the system which integer to start with.

MINVALUE. Tells the system how low the sequence can go. For ascending sequences, it defaults to 1; for descending sequences, the default value is 10e27-1.

MAXVALUE. Tells the system the highest value that will be allowed. For descending sequences, the default is 1; for ascending sequences, the default is 10e27-1.

CYCLE. Causes the sequences to automatically recycle to minvalue when maxvalue is reached for ascending sequences; for descending sequences, it causes a recycle from minvalue back to maxvalue.

CACHE. Caches the specified number of sequence values into the buffers in the SGA. This speeds access, but all cached numbers are lost when the database is shut down. The default value is 20; maximum value is maxvalue-minvalue.

ORDER. Forces sequence numbers to be output in order of request. In cases where they are used for timestamping, this may be required. In most cases, the sequences numbers will be in order anyway, so ORDER will not be required. ORDER is necessary only to guarantee ordered generation if you are using Oracle with the Oracle Real Application Clusters option in parallel mode. If you are using exclusive mode, Oracle sequences numbers are always generated in order.

See Altering Oracle sequences

See my notes on Oracle sequences here:


 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.