Alter Sequence SQL

This is a discussion on Alter Sequence SQL within the db2-udb forums in Other Databases category; ALTER SEQUENCE A_ID RESTART SELECT MAX(aid) + 1 FROM atable; Can I reset the sequence number like this? Thanks in advance....

Go Back   Database Forum > Other Databases > db2-udb

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-24-2007, 01:02 AM
Default Alter Sequence SQL

ALTER SEQUENCE A_ID RESTART SELECT MAX(aid) + 1 FROM atable;

Can I reset the sequence number like this?
Thanks in advance.
Reply With Quote
  #2  
Old 09-24-2007, 05:20 AM
Default Re: Alter Sequence SQL

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.
Reply With Quote
  #3  
Old 09-24-2007, 10:15 AM
Default Re: Alter Sequence SQL

calvinscy-at-hotmail.com wrote:

> 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/infoce...c/r0004200.htm

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 05:26 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Integrated by bbpixel2009 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.