insert range of values in a table

Database
Enthusiast

insert range of values in a table

I am new to teradata and not a big developer. Can anyone please suggest me how to insert range of values in a table. for Eg: i would like to insert data into the table between the range 1090 to 9000.

4 REPLIES
Enthusiast

Re: insert range of values in a table

You can try this SQL

SEL CSUM(1,1) + 1090 AS SEQ
FROM SYS_CALENDAR.CALENDAR
QUALIFY SEQ < 9000

This will give you the required sequence number, you can include this query in a subquery of INSERT-SELECT statement to populate the required table's field.

Regards,

Enthusiast

Re: insert range of values in a table

thanks!! this is useful

Senior Apprentice

Re: insert range of values in a table

Be careful, CSUM(1,1) is the same as ROW_NUMBER() OVER (ORDER BY 1).

And "ORDER BY 1" means order by the constant value 1, which results in skewed single AMP processing.

No problem for a small number of rows but bad for large data sets.

Better order by a more or less unique column. In your special case you could also use day_of_calendar instead of CSUM.

Dieter

Enthusiast

Re: insert range of values in a table

that makes sense!! I am trying to deal with only hundreds of records.