SQLite Forum

Efficient array data type
Login
> Hi, I'm trying to figure out if sqlite, or one of its
> extensions, supports efficient storage of arrays of various
> data types. For the problem at hand, of numbers and dates,
> but in general, of any SQLite supported data type.

Arrays are not supported as datatype for a column value in SQLite.

In relational databases, arrays are genrally stored as rows with as many key columns as the array has dimensions, and one value column.

Your question suggests you think that is not efficient, but doesn't have to be true. Just try it.

Alternatives I can think of:

* You could serrialize an array into a blob, but you will have to build that by yourself
* JSON arrays, yes they are probably much less space efficient than storing them the SQL way. 

```sql
CREATE TABLE My3Darray (
  x INTEGER NOT NULL -- dimension 1
, y INTEGER NOT NULL -- dimension 2
, z INTEGER NOT NULL -- dimension 3
, v REAL -- the proper type for julianday() dat3e/time stamps
, PRIMARY KEY (x,y,z)
);
```

~~~
-- 
Regards,
Kees Nuyt
~~~