I’m trying to add sequential numbers, from 1 to 200M, to an empty SQL table. The number is too large to make the list with Excel. I’m also using Cpanel which has a low file size limit. Any way to do this using an sql query? (Note: other posts have given sample code for this, but they don’t seem to be standard SQL queries that can be used in cpanel.)
Any advice will be appreciated.
2
Answers
The easiest way is to use
information_schema.columns
view.Simple SQLFiddle demo for 100.000 rows (only 100 thousand since I don’t want to kill SQLFiddle) – it takes only a few seconds:
If your database has, say, 100 columns, then the cross join of 4 tables can give 100^4 = 100000000 potential rows, this is much more than you need.
An iterative solution would be:
The drawback to this solution is that it will execute 2 million insert statements against your database.