SQLite Forum

Unexpected return from the NULL column
Login
Your statement:

```
ALTER TABLE v0 ADD COLUMN v3 AS ( NULL) NOT NULL;
```

Adds a virtual generated/computed at access time column with a value of NULL and adds a NOT NULL constraint.  There is no "default" value.

If you add a column with a default of null and a not null constraint, then the ALTER TABLE generates your expected error message:

```
sqlite> alter table v0 add column v3 not null;
Error: Cannot add a NOT NULL column with default value NULL
sqlite> alter table v0 add column v3 default null not null;
Error: Cannot add a NOT NULL column with default value NULL
```

SQLite3 is merely carrying out what you requested it to do.  SQLite3 does not make a guess as to whether or not what you have commanded is sensible but rather only produces an error if you have given a command that is obviously flawed.