I use this because later in an other program I must read the table. Each table has a size of 135 Mb!
A query for getting these results is too slow and too much time consumming.
When I create the table, reading a csv file, I prepare the different variables then at the end I write them without using CREATE TABLE and INSERT.
sqlite3_exec(hAsteroid, "DROP TABLE IF EXISTS V_MinAndMax;",0,0,NULL) ;
sqlite3_snprintf(sizeof(_szTmp),_szTmp,
"CREATE TABLE V_MinAndMax AS\n"
" SELECT\n"
" 1 AS RecNum,\n"
" %lu AS SpkId,\n"
" %lu AS BodyCenter,\n"
" \"%q\" AS Name,\n"
" %f AS Min_X,\n" // MIN X
" %f AS Min_Y,\n" // MIN Y
" %f AS Min_Z,\n" // MIN Z
" %f AS Max_X,\n" // MAX X
" %f AS Max_Y,\n" // MAX Y
" %f AS Max_Z,\n" // MAX Z
" %f AS Min_VX,\n" // MIN VX
" %f AS Min_VY,\n" // MIN VY
" %f AS Min_VZ,\n" // MIN VZ
" %f AS Max_VX,\n" // MAX VX
" %f AS Max_VY,\n" // MAX VY
" %f AS Max_VZ,\n" // MAX VZ
" %f AS DistanceLaPlusProche,\n" // MIN Racine(X² + Y² + Z²)
" %f AS DistanceLaPlusEloignee,\n" // MAX RacineVX² + Y² + Z²)
" %f AS VitesseLaPlusProche,\n" // MAX Racine(VX² + VY² + VZ²)
" %f AS VitesseLaPlusEloignee,\n", // MIN Racine(VX² + VY² + VZ²)
__iSpkId,__iFrom,__lpszAsteroidName,
_dMin_X,_dMin_Y,_dMin_Z,
_dMax_X,_dMax_Y,_dMax_Z,
_dMin_VX,_dMin_VY,_dMin_VZ,
_dMax_VX,_dMax_VY,_dMax_VZ,
sqrt(pow(_dMin_X,2) + pow(_dMin_Y,2) + pow(_dMin_Z,2)),
sqrt(pow(_dMax_X,2) + pow(_dMax_Y,2) + pow(_dMax_Z,2)),
sqrt(pow(_dMin_VX,2) + pow(_dMin_VY,2) + pow(_dMin_VZ,2)),
sqrt(pow(_dMax_VX,2) + pow(_dMax_VY,2) + pow(_dMax_VZ,2)),
_dDistanceLaPlusProche, _dDistanceLaPlusEloignee,
_dVitesseLaPlusProche, _dVitesseLaPlusEloignee) ;
I hope this will help someone.