how to generate addition row as counter

Analytics
Enthusiast

how to generate addition row as counter

hi,

i am needing help on how to create a table (No RAW data to insert) , only generate the count from 1 to 1000.

the final table will
Counter
1
.
.
.
1000

Thank you very much.
3 REPLIES
Enthusiast

Re: how to generate addition row as counter

Hi,

Create table as mentioned below and exec the foll. query.

CREATE SET TABLE ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT
(
ID_COL INTEGER GENERATED ALWAYS AS IDENTITY
(START WITH 1
INCREMENT BY 1
MINVALUE -2147483647
MAXVALUE 1000
NO CYCLE))
UNIQUE PRIMARY INDEX ( ID_COL );

INSERT INTO
SELECT 1 FROM DB_NAME.TABLE_NAME_2

Just make sure, above select query fetches the number of records you want. In this case 1000.
Junior Contributor

Re: how to generate addition row as counter

Hi Dhiraj,
did you try it, this will not work :-)

If it's less than 73000 values:
insert into tab
select day_of_calendar
from sys_calendar.calendar
where day_of_calendar <= 1000

Dieter
Enthusiast

Re: how to generate addition row as counter

Hi, it does not work. it did not fetch the record, only insert 1 record. the max value may go up to 999999999999999.

thanks,