如何在oracle中导出和导入BLOB数据类型

前端之家收集整理的这篇文章主要介绍了如何在oracle中导出和导入BLOB数据类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用任何工具在oracle中导出和导入BLOB数据类型.我想把它作为释放

解决方法

回答,因为即使它是一个5岁的问题它有一个不错的观点数…

自5年前提出这个问题以来,有一个名为sqlcl的新工具(http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html)

我们将sqlDEV中的脚本引擎分解为cmd行. sqlDev和它基于java,它允许使用nashorn / javascript引擎进行客户端脚本编写.这是一个简短的例子,可以选择3列. ID只是表PK,命名要创建的文件名称,以及要从db中提取的BLOB的内容.

script命令会触发此脚本.我将下面的代码放在一个名为blob2file.sql文件

所有这些加起来是零plsql,零目录而不是一些混合了javascript的sql脚本.

script
// issue the sql
// bind if needed but not in this case
var binds = {}
var  ret = util.executeReturnList('select id,name,content from images',binds);

// loop the results
for (i = 0; i < ret.length; i++) {
   // debug messages
    ctx.write( ret[i].ID  + "\t" + ret[i].NAME+ "\n");

   // get the blob stream    
     var blobStream =  ret[i].CONTENT.getBinaryStream(1);

   // get the path/file handle to write to
   // replace as need to write file to another location
     var path = java.nio.file.FileSystems.getDefault().getPath(ret[i].NAME);

   // dump the file stream to the file
     java.nio.file.Files.copy(blobStream,path);
}
/

结果是我的表被清空到文件中(我只有1行).只需像任何普通的sql脚本一样运行.

sql>  @blob2file.sql
1   eclipse.png
blob2file.sql   eclipse.png

sql>

猜你在找的Oracle相关文章