如何在oracle中导出和导入BLOB数据类型
发布时间:2021-01-13 06:11:39 所属栏目:站长百科 来源:网络整理
导读:如何使用任何工具在oracle中导出和导入BLOB数据类型.我想把它作为释放 解决方法 回答,因为即使它是一个5岁的问题它有一个不错的观点数… 自5年前提出这个问题以来,有一个名为SQLcl的新工具(http://www.oracle.com/technetwork/developer-tools/sqlcl/overvie
如何使用任何工具在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> (编辑:青岛站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐