~/snippets/create-million-rows-single-query
Published on

Create Million Rows with Single Query

117 words1 min read
-- Create a table to hold the data
CREATE TABLE temp (t int);

-- Insert 1,000,000 rows with random integers into the 'temp' table
INSERT INTO temp (t)
SELECT trunc(random() * 100)
FROM generate_series(1, 1000000);