如何在oracle中导出和导入BLOB数据类型
发布时间:2021-01-13 07:05:23 所属栏目:站长百科 来源:网络整理
导读:怎样行使任何器材在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> (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |