Live data from Hacker News

How to create a 1M record table with a single query

antonz.org

1–10 of 40 posts

Re: How to create a 1M record table with a single query

#4
If you're running PostgreSQL, you can use the built-in generate_series (1) function like:

  SELECT id, random()
  FROM generate_series(0, 1000000) g (id);
There seems to be an equivalent in SQLite: https://sqlite.org/series.html

[1] https://www.postgresql.org/docs/current/functions-srf.html

Re: How to create a 1M record table with a single query

#7

> This is not a problem if your DBMS supports SQL recursion A table of which DMBS’s support this would be useful

This is the list that i could find:

Microsoft SQL Server, Firebird 2.1, PostgreSQL, SQLite, IBM Informix version, CUBRID, MariaDB and MySQL

Re: How to create a 1M record table with a single query

#9
post #6

Can someone give me a specific use case for this? As "check how a query behaves on a large table" is very vague to me. E.g. I have a table structure but not alot of rows in it, so i go use this to get alot of rows in to check how fast queries get processed?

Exactly like that, yes.

Re: How to create a 1M record table with a single query

#10
post #7

> This is not a problem if your DBMS supports SQL recursion A table of which DMBS’s support this would be useful

This is the list that i could find: Microsoft SQL Server, Firebird 2.1, PostgreSQL, SQLite, IBM Informix version, CUBRID, MariaDB and MySQL

Not oracle?
Post reply on HN