Discussion:
Alter Sequence SQL
(too old to reply)
c***@hotmail.com
2007-09-24 04:02:48 UTC
Permalink
ALTER SEQUENCE A_ID RESTART SELECT MAX(aid) + 1 FROM atable;

Can I reset the sequence number like this?
Thanks in advance.
c***@hotmail.com
2007-09-24 08:20:37 UTC
Permalink
Actual what I want to do is to combine following sql into one:

SELECT MAX(c.order_id)
FROM customer_orders_t c

ALTER SEQUENCE orders_seq
RESTART WITH 57232

Get the max number of the table id,
and reset the starting sequence number.

Thanks.
Knut Stolze
2007-09-24 13:15:51 UTC
Permalink
Post by c***@hotmail.com
ALTER SEQUENCE A_ID RESTART SELECT MAX(aid) + 1 FROM atable;
Can I reset the sequence number like this?
No, you can't. After RESTART must come a numeric constant and not a
subselect or some other expression.

http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0004200.htm
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Loading...