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.

demandé il y a 4 mois194 vues
1 réponse
0
Réponse acceptée

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

répondu il y a 4 mois
profile pictureAWS
EXPERT
vérifié il y a 4 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions