如何使用任何工具在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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。