[sqlite] Wish list: better ALTER TABLE for setting default

2016-02-17 Thread Christian Schmitz

>> ALTER TABLE testTable SET DEFAULT FOR testField TO 0
> 
> Not all values in this column might actually be stored on disk.
> Changing the default value could change those rows.

it would be perfectly okay if you document this to either
* apply the new default to all NULL values
* not change existing rows. Than I do the UPDATE Statement myself.

> It is actually possible to do this, if you force all rows to be
> rewritten first, and then change the table definition:
> http://stackoverflow.com/questions/25911191/altering-a-sqlite-table-to-add-a-timestamp-column-with-default-value

You really want us to modify the Table Definitions?


Sincerely
Christian

-- 
Read our blog about news on our plugins:

http://www.mbsplugins.de/



[sqlite] Wish list: better ALTER TABLE for setting default

2016-02-17 Thread Clemens Ladisch
Christian Schmitz wrote:
> I would like to see more alter table things.

Currently, ALTER TABLE implements only those changes that can be done
without rewriting any of the table data.

> ALTER TABLE testTable SET DEFAULT FOR testField TO 0

Not all values in this column might actually be stored on disk.
Changing the default value could change those rows.

It is actually possible to do this, if you force all rows to be
rewritten first, and then change the table definition:
http://stackoverflow.com/questions/25911191/altering-a-sqlite-table-to-add-a-timestamp-column-with-default-value

> ALTER TABLE testTable SET UNIQUE FOR testField TO 1

You can already do the same with an index.
(Renaming that index to "sqlite_autoindex_testTable_n" and adjusting the
table definition is left as an exercise.)


Regards,
Clemens


[sqlite] Wish list: better ALTER TABLE for setting default

2016-02-17 Thread Christian Schmitz
Hi,

Sometimes I add columns to tables.
But when I forget an option, I can't do much, but going back to backup copy or 
creating a copy of whole database with little change.

e.g. a column misses default value.

So I would like to see more alter table things.
Maybe like this:


ALTER TABLE testTable SET DEFAULT FOR testField TO 0

or

ALTER TABLE testTable SET UNIQUE FOR testField TO 1


Sincerely
Christian

-- 
Read our blog about news on our plugins:

http://www.mbsplugins.de/