sql - Generate numbers between min_value and max_value oracle -


i have 2 methods solution, both high inefficient work value of order 108 , greater.

method 1

 select 100 + rownum - 1 dual connect level <= (200 - 100 + 1) 

method 2

select rownum + 100 - 1 (select 1 dual group cube(1, 2, 3, 4, 5, 6, 7, 8, 9)) rownum < (200 - 100 + 1) 

but first method fails when max value 100,000,000 , second method takes lot of time process.

please suggest efficient method, think of sequences suppose time cost higher.

update

error in first method

ora-30009: not enough memory connect operation

for many rows pipelined function best solution:

create or replace type t_numbers table of number; /  create or replace function generate_series(p_min integer, p_max integer)   return t_numbers pipelined   begin   in p_min..p_max loop     pipe row (i);   end loop; end; / 

a simple:

select count(*) table(generate_series(1,100000000)); 

this takes 30 seconds on laptop


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -