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

What is the difference between substr and instr?

498


What is a cursor variable?

553


Explain the blob datatype?

592


What are the differences between char and varchar2 in oracle?

541


Explain the use of Merge statement in oracle 11g

570






What is a sub query? What are its various types?

559


What are the attributes of cursor?

563


How to loop through data rows in the implicit cursor?

519


What are oracle functions?

530


What is a partition in oracle?

521


Who developed oracle & when?

550


Can select statements be used on views in oracle?

571


What is oracle rownum?

493


What is snapshot is too old? Give and example for better understand.

1077


Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size ?

1846