sqlite - Default column value during and after adding a column -
if specify default when adding non-null column table ...
alter table foo add column bar int default 42 not null
... bar
column continue have default value? or default used while adding column, specify values in existing rows?
the documentation says:
the column-def rule defines characteristics of new column.
so default value applies column, not operation:
sqlite> create table foo(x); sqlite> alter table foo add column bar int default 42 not null; sqlite> insert foo(x) values(1); sqlite> select * foo; 1|42
Comments
Post a Comment