SQLite Forum

Serious problems with STORED columns
Login
Create an empty database and run this script a few times **a few seconds** apart.

```
CREATE TABLE IF NOT EXISTS xxx.log(
  dt text as (datetime()) stored,                 --datetime of event
  msg text collate nocase not null,               --message
  unique (dt,msg)
  );

insert into log(msg) values('a');
insert into log(msg) values('b');
insert into log(msg) values('c');
```

Now, `.dump` the database (or just the one table `log`) to a file:

`sqlite3 sample.db ".d log" > sample.sql`

Problems:

1. The `dt` column is not part of the dump.  So, all that very important information is lost in the backup.
   You can no longer restore the database to its original content.

2. Because of the use of the `datetime()` function in the table definition, attempting to create the database by feeding the dump, gives a sequence of `UNIQUE constraint failed: log.dt, log.msg` errors as there are multiple identical record insertions attempted.

My suggested solution is the introduction of some `pragma` that will allow loading `stored` columns directly as if they were regular columns.  This can be part of the dump to allow correct restoration of the table.  The dump should include stored columns too (except for non-stored generated ones).