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.

posta 4 mesi fa194 visualizzazioni
1 Risposta
0
Risposta accettata

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

con risposta 4 mesi fa
profile pictureAWS
ESPERTO
verificato 4 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande