blob to float conversion
am 01.09.2006 23:46:26 von yoes
Dear all,
I am very new in MySQL, I am working on image database project for my
research and I have problem how to convert blob field into float in
MySQL so that I can calculate the blob field with the MATH operation.
Does any one how to do it ????
Thank you very much indeed , for your help.
Regards
yoesufi
Re: blob to float conversion
am 02.09.2006 23:30:56 von Aggro
yoes wrote:
> I am very new in MySQL, I am working on image database project for my
> research and I have problem how to convert blob field into float in
> MySQL so that I can calculate the blob field with the MATH operation.
If I understood you correctly, you have a field in your table and you
want to change the type of this field and at the same time calculate a
different value for it, but use the old value to do so. If so...
To minimize the risk of the data loss, to keep system down as little as
possible and to make it easy, I suggest that you first create a new
field first. Then put the correct value to that field and then remove
the blob and then rename the new field to the name what blob had.
Something like:
alter table yourtablename add newfield float;
update yourtablename set newfield = 1+1; # add correct formula here
# Now is a good place to check that the newfield
# actually has correct values
alter table yourtablename drop blobfield;
alter table yourtablename change newfield blobfield float;
If the database has users 24/7 and you are creating the float value from
always changing data, you should lock the table for that operation to
prevent anyone changing the values while working.
Those commands were written from memory, without checking if they
actually work. Please use with caution.