Sequence_Creation

Hi Expert,

We create sequence with Trigger has good idea or simply used sequence start with 1, increment by 1 in oracle.

Please suggest which one is good choice and why ??

Thanks in Advance .
MIHIR KAROracle DB beginnerAsked:
Who is Participating?
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
I assume by trigger you mean go find the greatest value and add 1 to it.  That is HORRIBLE and should NEVER be done.

Why:  It can take a lot of SQL time to generate the MAX and it doesn't get you anything.   They can also lead to duplicate values.

Oracle sequences are fast to increment and cannot generate duplicates.

Assuming the next part of the question:
Neither by themselves will generate gapless numbers.  It is rare that you MUST have them.  Most of the time DBAs/Developers/Analysts just like them but really don't have a requirement to have them.
0
 
Pawan KumarConnect With a Mentor Database ExpertCommented:
sequence start with 1, increment by 1 in oracle
This one is good.

But before that please tell us your complete requirement? What you are trying to achieve?
0
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
>> We create sequence with Trigger
You create a sequence by means of a trigger? A sequence is usually not created by a trigger but during setup or modification of a table.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.