How can we manage the gap in a primary key column created
by a sequence?
Ex:a company has empno as primary key generated by a
sequence and some employees leaves in between.What is the
best way to manage this gap?

Answer Posted / poornima

using cursor we find the gap in sequence, but this method
is quite complicated and slow process...

so we use some analyical fuctions such as lead and lag as

{LEAD | LAG} (value_expression, offset, default)
OVER ([PARTITION BY expr] ORDER BY expr)

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is oracle the best database?

709


How to define a data source name (dsn) in odbc manager?

754


What is primefaces used for?

782


How can I introduce multiple conditions in like operator?

731


Can we store pictures in the database and if so, how it can be done?

790


What is recovery manager in Oracle?

812


What is transaction control statement and how many types of transaction control statement in Oracle?

807


What is sharded cluster?

707


How to unlock the sample user account in oracle?

720


What is background process in Oracle?

835


What is the difference between formal parameters and actual parameters?

737


Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.

1894


How are extents allocated to a segment?

780


Explain the use of compress option in exp command.

741


how to join query for one source type is oracle another source type is sql server ?

2198