MySQL: Return the size of a blob
February 28th, 2008 by jason
Ok, lets say you have stored a file as a blob in a database (maybe its something important) and you would like to print the size of the blob file to screen. This can be done quite easily by doing a query making use of the MySQL function OCTET_LENGTH()
For example:
SELECT OCTET_LENGTH(blob) FROM table
Blob being the column and table being the table in the database. The number returned is the size of the blob in bytes
There you go, quite easy to do but hard to find!
Posted in General Opensource
February 29th, 2008 at 4:17 am
I take it you needed to find out your blob file size? Just curious, why? is it a file for download?
Thanks for taking the trouble. It’s always good, because one day I will need this - and THEN it will be avaliable through a Google search.
March 1st, 2008 at 3:03 am
Hi Micheal, yes thats pretty much the use of it. My actual use for it was a little more complex, but the is the idea. This article was kind of a book mark for me, you’d be surprised how hard it was to find hehehe