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.

질문됨 4달 전193회 조회
1개 답변
0
수락된 답변

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

답변함 4달 전
profile pictureAWS
전문가
검토됨 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠