- Original Message -
From: Alexey Pechnikov
Newsgroups: gmane.comp.db.sqlite.general
Sent: Saturday, May 08, 2010 2:27 PM
Subject: Re: Returning column to default
Please send to me this patch. I think it may be added to unofficial
http://sqlite.mobigroup.ru repository.
No problems.
Please send to me this patch. I think it may be added to unofficial
http://sqlite.mobigroup.ru repository.
2010/5/7 Andy Gibbs andyg1...@hotmail.co.uk:
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
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
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
On Thu, May 06, 2010 at 04:11:43PM +0200, Andy Gibbs scratched on the wall:
Is it possible to do this in sqlite?
No.
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
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
Thanks for the speedy response.
Unfortunately, it's not seemingly possible to do...
UPDATE tab SET col = (SELECT dflt_value FROM (PRAGMA table_info(tab)));
... which certainly does make it a pain. Plus this doesn't work anyway
where dflt_value is not a constant, but an expression (e.g.
You could write a trigger that sets default value if NULL is inserted
or set via UPDATE.
That's a great idea - thanks! It won't work in all the places since in some
places 'NULL' is a valid value, but I'm sure I can think of a work-around.
Thank you!!
Is there a primary key on the table?
Is it possible to use insert or replace instead of update, and then not
reference the column you want to set as a default?
On Thu, May 6, 2010 at 10:41 AM, Andy Gibbs andyg1...@hotmail.co.uk wrote:
You could write a trigger that sets default value if NULL
Adam,
Is there a primary key on the table?
Is it possible to use insert or replace instead of update, and then not
reference the column you want to set as a default?
An interesting idea. Unfortunately, I think in my case it would be too much
of a performance hit since I would be updating
10 matches
Mail list logo