How to accomplish this in Teradata

Database
Enthusiast

How to accomplish this in Teradata

Hi,

I need to generate the sequence ids. So here is my plan.

1) Lock table (not sure which lock level method should use)
2) select max(id)+1 into variable from table
3) update table set id=max(id)+1
4)unlock table.

For that, how can I do it in Teradata.

Thnx in advance,
JMM
2 REPLIES
Enthusiast

Re: How to accomplish this in Teradata

Try using functions like Row_Number and Rank. Or try to define the column as Identity column.

Refer Teradata documentation regarding the above mentioned functions
Enthusiast

Re: How to accomplish this in Teradata

lock table for write
update table set key=value
select max(col)+1 as value from table
release lock