Cleaning Up Oracle Sequences -


i've worked extensively sql server have little experience oracle. i've been given task of "cleaning up" sequences in oracle database , not sure how go safely.

i need determine maximum value in table (say id = 105). , see next sequence id is. if 106, good. if 110, need reset 106.

can safely drop sequence recreate or muck existing primary key? i'm guessing wouldn't problem before jacked else's system, wanted ask.

this command going use

drop sequence blah.foo_seq create sequence blah.foo_seq start 106 min 1 max 2147483647 yada yada 

i'd wary need "clean up" oracle sequence. since oracle sequences cannot used generate gap-free values, if 110 cause problem application, there bigger problems need addressed.

dropping sequence has no impact on primary key. invalidate objects reference sequence , remove privilege grants. can recompile code after you've re-created sequence, it's dropping of privileges potentially problematic.

an alternative approach avoids need deal lost privileges change increment parameter decrease sequence value, i.e.

alter sequence foo_seq   increment -4;  select foo_seq.nextval   dual;  alter sequence foo_seq   increment 1; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -