jeudi 24 mars 2016

Why do column types differ between select and create table as select?

Say, I have 2-column table with NUMERIC columns with some data

When using sqlite C api and trying a simple 0-bounded select:

select A,B,SUM(A+B) limit 0

then getting the types via C api, the types of the columns would be returned correctly as SQLITE_FLOAT

However, if I do create table as select:

create temp table A as select A,B,SUM(A+B)

Then try to get types again from a 0-bounded select:

select * from A limit 0

I get SQLITE_NULL back as type for the 'computed' column:

SQLITE_FLOAT,SQLITE_FLOAT,SQLITE_NULL

Why is it the case? Can I force create temp table to still try to guess column affinity, to avoid null type?

Aucun commentaire:

Enregistrer un commentaire