Unable to fill temp table with numbers in Amazon Redshift, row count is less than expected

0

The goal is to create a temp table with consecutive numbers from 1 to 25567. I tried this SQL statements:

-- Create temp table
DROP TABLE IF EXISTS numbers;

CREATE TEMP TABLE numbers 
(
    n INT NOT NULL PRIMARY KEY
);

-- Insert numbers from 1 to 25567
INSERT INTO numbers
    SELECT ROW_NUMBER() OVER () AS n
    FROM stl_scan
    LIMIT 25567;

SELECT COUNT(*) FROM numbers

3632

Why are there less rows than expected? and instead of starting at 1, the first row is 4, and goes on by 4 (8, 12, 16, and so on). I tried adding ORDER BY but the result is the same.

asked 4 months ago183 views
1 Answer
0
Accepted Answer

I solved it by uploading a csv file with the numbers to S3 and using the COPY command to the numbers table.

answered 4 months ago
profile pictureAWS
EXPERT
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions