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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -