manoj_cts
asked on
Oracle Sequence - Last value need to be Max of primary key column +1
How to alter my sequence so that last value of sequence should be one more than the max value value of primary key cloumn of the table.
It seems i need to have a procedure which will alter all the sequences at one shot.
Could any one suggest me on this..
It seems i need to have a procedure which will alter all the sequences at one shot.
Could any one suggest me on this..
ASKER
This is fine but it will can be done every time.I want to have a procedure which will do it for all the sequences.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-- Get max value of current pk
Select MAX(MY_PK) + 1 FROM MY_TABLE;
-- returns...
12345
-- drop and recreate sequence
DROP SEQUENCE MY_SEQUENCE;
CREATE SEQUENCE MY_SEQUENCE START WITH 12345 increment by 1 ...yadda yadda yadda
HTH,
Mark