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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则