The comment approach could work, I guess, but why not just encode the type into 
the column's declared type?

CREATE TABLE blob_table (
  ModelNo TEXT,
  SerialNo TEXT,
  VSWR BLOB_DOUBLE
)

That's what I do with numeric columns that I need to identify as actually 
containing dates.  As I understand it, SQLite only scans those type names to 
choose a column affinity, so you are free to be as creative with them as you 
want.  sqlite3_column_decltype() will return whatever you put as the type.

HTH,

Eric

Sent from Windows Mail

From: William Drago<mailto:wdr...@suffolk.lib.ny.us>
Sent: ?Saturday?, ?May? ?9?, ?2015 ?7?:?18? ?AM
To: sqlite-users at mailinglists.sqlite.org<mailto:sqlite-users at 
mailinglists.sqlite.org>

On 5/9/2015 6:40 AM, Eduardo Morras wrote:
> On Sat, 09 May 2015 06:09:41 -0400
> William Drago <wdrago at suffolk.lib.ny.us> wrote:
>
>> All,
>>
>> Say you encounter a blob in a database. There's no way to
>> tell if that blob carries bytes, floats, doubles, etc, correct?
>>
>> Assuming the above is true, then is it always prudent to
>> store some metadata along with your blobs so that they can
>> be identified in the future?
>>
>> Example table:
>>
>> ModelNo TEXT (e.g. SO-239)
>> SerialNo TEXT (e.g. 101)
>> VSWR BLOB (e.g. x'feab12c...')
>> VSWR_Type TEXT (e.g. double)
>>
>>
>> Does this make sense?
> You can use SQL comments on CREATE TABLE, those comments aren't deleted from 
> SQLITE_MASTER table, you can query it as a normal table.
>
> CREATE TABLE blob_table (
>   ModelNo TEXT,  -- e.g. S0-239
>   SerialNo TEXT, -- e.g. 101
>   VSWR BLOB      -- double, e.g. x'feab12c....'
> );
>
> SELECT sql from sqlite_master where type='table' AND tbl_name='blob_table';
>
> will return
>
> CREATE TABLE blob_table (
>   ModelNo TEXT,  -- e.g. S0-239
>   SerialNo TEXT, -- e.g. 101
>   VSWR BLOB      -- double, e.g. x'feab12c....'
> )

This is a clever idea and saves the addition of a column
just for blob type. Is this a reliable feature of SQLite?
Does anyone see any issues with this as opposed to using a
dedicated column?

Thanks,
-Bill


_______________________________________________
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to