How to insert random data into a SQLite table using only queries?
You can use a recursive query.
This query generates a table with 1000 random numbers:
CREATE TABLE test(field1);
INSERT INTO test
WITH RECURSIVE
cte(x) AS (
SELECT random()
UNION ALL
SELECT random()
FROM cte
LIMIT 1000
)
SELECT x FROM cte;
Going for hacky, this'll insert up to 2048 random rows in one go, decide how many by setting the limit;
INSERT INTO TEST (x,y,z)
SELECT RANDOM(), RANDOM(), RANDOM()
FROM (SELECT * FROM (
(SELECT 0 UNION ALL SELECT 1) t2,
(SELECT 0 UNION ALL SELECT 1) t4,
(SELECT 0 UNION ALL SELECT 1) t8,
(SELECT 0 UNION ALL SELECT 1) t16,
(SELECT 0 UNION ALL SELECT 1) t32,
(SELECT 0 UNION ALL SELECT 1) t64,
(SELECT 0 UNION ALL SELECT 1) t128,
(SELECT 0 UNION ALL SELECT 1) t256,
(SELECT 0 UNION ALL SELECT 1) t512,
(SELECT 0 UNION ALL SELECT 1) t1024,
(SELECT 0 UNION ALL SELECT 1) t2048
)
) LIMIT 246;