> I know it would be possible to simply hard-code the default value into the > UPDATE statement, but this would mean when updating the default in the table > declaration, I then need to make sure all the UPDATEs match!
You could write a trigger that sets default value if NULL is inserted or set via UPDATE. BTW, only via trigger you can actually change default in production database on the fly. Otherwise SQLite doesn't allow to change definition of already existing columns, so you wouldn't be able to do that on the fly. Pavel On Thu, May 6, 2010 at 10:11 AM, Andy Gibbs <andyg1...@hotmail.co.uk> wrote: > Hi, > > I hope I haven't missed something in the documentation, but I can't find a > statement to return a column value to its default. > > If I have the following table: > > CREATE TABLE tab (col TEXT DEFAULT "some_default", ....); > > I can insert with defaults using > > INSERT INTO tab DEFAULT VALUES > > But there doesn't seem to be a corresponding > > UPDATE tab SET col DEFAULT VALUES > > or > > UPDATE tab SET col = DEFAULT > > (the latter statement was thrown up by Google as the way to do it on another > database architecture - Microsoft's I think). > > Is it possible to do this in sqlite? I know it would be possible to simply > hard-code the default value into the UPDATE statement, but this would mean > when updating the default in the table declaration, I then need to make sure > all the UPDATEs match! > > Thanks > Andy > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users