Search code examples
sqldb2blob

Extract BLOB File as multiple files in DB2


I want to extract original files stored as BLOB in DB2 database. I used this DB2 command:

EXPORT TO MyFile.DEL OF DEL LOBS TO . LOBFILE lob SELECT BLOB_COL 
FROM MY_TABLE where REPORT_ID in
(select report_id from My_TABLE2 where CONDITION)

I get a .blob file that contains the content of all the files. Now I am wondering if there is a way to export each file in a single file instead of having them gathered in the same file.

Is this possible in DB2 ?


Solution

  • It is possible in recent versions of DB2 for LUW (beginning at least with v9.5) by specifying the lobsinsepfiles modifier:

    EXPORT TO MyFile.DEL OF DEL LOBS TO . LOBFILE lob 
    MODIFIED BY lobsinsepfiles
    SELECT ...