Search code examples
sqlidiomsmonetdbdata-generation

How do I generate a (dummy) column of arbitrary length with MonetDB?


I would like to run the equivalent of PostgreSQL's

SELECT * FROM GENERATE_SERIES(1, 10000000)

I've read this:

http://blog.jooq.org/2013/11/19/how-to-create-a-range-from-1-to-10-in-sql/

But most suggestions there don't really take an arbitrary length - the query depends on the length otherwise than by just replacing a number. Also, some suggestions do not apply in MonetDB. So, what's my best course of action (if any)?

Notes: - I'm using a version from February 2013. Answers about more recent features are also welcome, but are exactly what I'm looking for. - Assume the existing tables don't have enough lines; and do not assume that, say, a Cartesian product of the longest table with itself is sufficient (or alternatively, maybe that's too costly to perform).


Solution

  • Try with:

    SELECT value
    FROM sys.generate_series(initial_value, end_value, offset);
    

    I have to report that the function is quite unstable on Jul2015 release as is causing the server process to crash. Hope you have better luck.

    If you wants to generate an arbitrary numeric value you can use:

    SELECT rand();