开发者

query part of a binary field from sql table

开发者 https://www.devze.com 2022-12-08 12:46 出处:网络
a bit newb question: in my DB I\'ve got a table with a binary field. I\'d like to fetch not that whole field in a request, but rather part of it, preferably using ODBC. Is it at all possible? I\'m usi

a bit newb question: in my DB I've got a table with a binary field. I'd like to fetch not that whole field in a request, but rather part of it, preferably using ODBC. Is it at all possible? I'm using PostgreSQL开发者_如何学运维 8.3 - in case a solution exists for that specific DBMS. Thanks.

Getting data part-by-part seems to be possible with SQLGetData function, but I'd also like to just skip a part of the blob, without loading it. So the question can be formulated as follows: is it possible to skip some bytes when reading a blob by SQLGetData?


If by blob you mean PostgreSQL bytea, then you can just use select substring(bytea_column from ? for ?).

It is fast when data blob is not compressed - you should prevent automatic compression of bytea using alter table tablename alter column bytea_column set storage external. Only rows inserted after alter table will not be compressed so you should do it on empty table or delete and reinsert all data after this command.

I'm using it to retrieve blobs (binary file data like DOC or PDF) from database in chunks. Works well.

0

精彩评论

暂无评论...
验证码 换一张
取 消