将BLOB从文件插入数据库的ETL脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将BLOB从文件插入数据库的ETL脚本相关的知识,希望对你有一定的参考价值。

Scriptella ETL allows inserting files into a database. This is achieved by a simple bind variables extension syntax ?{file ...}.
The following sample initializes table of music tracks. Each track has a DATA field containing a file loaded from an external location. File song1.mp3 is stored in the same directory as etl.xml and song2.mp3 is loaded from the web:
  1. <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
  2. <etl>
  3. <connection driver="hsqldb" url="jdbc:hsqldb:file:tracks" user="sa" classpath="hsqldb.jar"/>
  4. <script>
  5. CREATE TABLE Track (
  6. ID INT,
  7. ALBUM_ID INT,
  8. NAME VARCHAR(100),
  9. DATA LONGVARBINARY
  10. );
  11. <!-- Inserts file with path relative to ETL script location -->
  12. INSERT INTO Track(id, album_id, name, data) VALUES
  13. (1, 1, 'Song1.mp3', ?{file 'song1.mp3'});
  14. <!-- Inserts file from an external URL-->
  15. INSERT INTO Track(id, album_id, name, data) VALUES
  16. (2, 2, 'Song2.mp3', ?{file 'http://musicstoresample.com/song2.mp3'});
  17. </script>
  18. </etl>

以上是关于将BLOB从文件插入数据库的ETL脚本的主要内容,如果未能解决你的问题,请参考以下文章

将 blob 数据插入数据库

SSIS ETL过程设计建议

使用 PL/SQL 将 base64 图像解码为 BLOB

从 Azure Blob 存储批量插入时出现 ERRORFILE 问题

Azure SQL - 从 Azure 文件而不是 Blob 批量插入

NPM Oracle:插入 BLOB