Hi,

I had a free couple of minutes, so I went in and added the functionality to 
sqlite since it was so straight-forward, so that it is now possible to do 
the following...

UPDATE tab SET col = DEFAULT

I chose this syntax since it is the syntax used by MS SQL Server and MySQL 
(and maybe others).

The patch is a mere 20 lines (including comments).  I have tested it for 
standard tables, but not for virtual tables, etc.  If anyone is interested 
in the patch, I would be very interested to hear how well it works.

Regards
Andy


----- Original Message ----- 
From: "Andy Gibbs"
Sent: Thursday, May 06, 2010 4:11 PM
Subject: Returning column to default


> 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

Reply via email to