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 are archived logs?

1717


What privilege is needed for a user to insert rows to tables in another schema?

561


How to fetch the row which has the max value for a column?

538


What is oracle sid?

509


what are actual and formal parameters?

596






What are the limitations oracle database 10g xe?

572


How to convert csv to table in oracle?

528


How will you write a query to get a 5th rank student from a table student_report?

1376


What is a nested table?

628


Why oracle is used?

580


How to install oracle database 10g xe?

562


What are the uses of Database Trigger ?

1101


Is java required for oracle client?

548


How to write text literals in oracle?

612


What is a read write transaction in oracle?

606