On 9/27/06, James W. Walker <[EMAIL PROTECTED]> wrote:

What is the fastest way to change the values in one column in every
row?  What I thought of was like so:

BEGIN TRANSACTION;
UPDATE MyTable SET TheCol=7 WHERE keyCol=1;
UPDATE MyTable SET TheCol=8 WHERE keyCol=2;
... and so on for each row
COMMIT;

Kurt Welgehausen <[EMAIL PROTECTED]> wrote on 10 Jan 2004:
>  What you propose will work, but you haven't given enough
>  info for anyone to tell you whether it's the best solution.

I'm not sure what other information would be helpful.  The table has
38 columns, a few of which may be fairly large blobs.  The number of
rows is obviously variable, but let's say it's on the order of 1000.

If the column values are algorithmically related to each other, then
you can have sqlite do it in one pass, possibly using custom functions
to determine relationship.  For the simple example you gave, something
like:

UPDATE MyTable SET TheCol = keyCol + 6;

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to