SQLite Forum

Is `JSON` a valid `create table` type?
Login
As documented by the previous response.  Your table definition, after correcting syntax errors, results in the following internal schema structure data:

```
sqlite> CREATE TABLE row_a (
   ...> row_a_id INTEGER PRIMARY KEY AUTOINCREMENT,
   ...> doc JSON NOT NULL
   ...> );
sqlite> pragma table_xinfo(row_a);
┌─────┬──────────┬─────────┬─────────┬──────┬─────────┬────────────┬────┬───────┬─────────┬────────┐
│ cid │   name   │  type   │   aff   │ coll │ notnull │ dflt_value │ pk │ rowid │ autoinc │ hidden │
├─────┼──────────┼─────────┼─────────┼──────┼─────────┼────────────┼────┼───────┼─────────┼────────┤
│ 0   │ row_a_id │ INTEGER │ INTEGER │      │ 0       │            │ 1  │ 1     │ 1       │ 0      │
│ 1   │ doc      │ JSON    │ NUMERIC │      │ 1       │            │ 0  │ 0     │ 0       │ 0      │
└─────┴──────────┴─────────┴─────────┴──────┴─────────┴────────────┴────┴───────┴─────────┴────────┘
```

**Note:**  I have modified the pragma to return additional information from the internal schema information structures and that your results will not contain all the columns.

The "type" can bee whatever you you wish it to be:

```
sqlite> create table t
   ...> (
   ...>   x Jolly Little Elephant Herding Mice not null,
   ...>   y integer
   ...> );
sqlite> pragma table_xinfo(t);
┌─────┬──────┬────────────────────────────────────┬─────────┬──────┬─────────┬────────────┬────┬───────┬─────────┬────────┐
│ cid │ name │                type                │   aff   │ coll │ notnull │ dflt_value │ pk │ rowid │ autoinc │ hidden │
├─────┼──────┼────────────────────────────────────┼─────────┼──────┼─────────┼────────────┼────┼───────┼─────────┼────────┤
│ -1  │      │                                    │ INTEGER │      │ 0       │            │ 1  │ 1     │ 0       │ 1      │
│ 0   │ x    │ Jolly Little Elephant Herding Mice │ NUMERIC │      │ 1       │            │ 0  │ 0     │ 0       │ 0      │
│ 1   │ y    │ integer                            │ INTEGER │      │ 0       │            │ 0  │ 0     │ 0       │ 0      │
└─────┴──────┴────────────────────────────────────┴─────────┴──────┴─────────┴────────────┴────┴───────┴─────────┴────────┘
```

**Note:**  I have also modified the pragma to return additional rows such as the implicit rowid which are not returned by the distributed code.

The "column affinity" is set in accordance with the rules set out in <https://sqlite.org/datatype3.html> and that the "type name" is an arbitrary string.