If you're asking "if a field on a row contains a value that was previously
defined a value due to the DEFAULT value in the schema, would this value be
changed if the in the schema later changed", then no, it doesn't change.
There is no reference to the default value in the schema once the data has
been inserted.  So if you have a DEFAULT 'ABC', insert 100 rows, then
change the schema to DEFAULT 'DEF', then the 100 rows would still contain
'ABC'.  If you add a new field to the database with a DEFAULT 'XYZ' then
that new field in ALL existing rows would contain 'XYZ' but 'ABC' or 'DEF'
would still exist.

The action SQLite takes when inserting physical data into the field is
based on what the current DEFAULT value is in the schema.  If you have two
fields, one that has to be defined on an insert and one with a default
value, SQLite will basically change this:

*insert into MyTable (Letters) values ('ABC')*

into

*insert into MyTable (Letters, DefaultsToABC) values ('ABC','ABC')*

Think of it this way;

If you had a table with a default value, and you go to enter a value
manually that just happens to match the schemas default value, it wouldn't
make sense to change the value of that value in an existing row if you
change the default value in the schema.  Based on the output of a SQL
command, you wouldn't be able to tell the difference if 'ABC' is the
default value or if 'ABC' was manually entered.  So if you go and change
the value of the default and SQLite DID go and change the default values,
you'd get confused to why you have some rows with 'ABC' and some with 'DEF'.

On Sun, Oct 26, 2014 at 1:40 PM, J Decker <d3c...@gmail.com> wrote:

>
> That is interesting; so if I alter the default values, all rows that
> existed before the column added and the default change get the changed
> value? .
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to