【问题标题】:Inserting blob in oracle DB where I don't have permissions to create tables在我无权创建表的 oracle DB 中插入 blob
【发布时间】:2018-03-10 04:10:53
【问题描述】:

我正在研究堆栈溢出,以了解在 oracle 中插入 blob 数据的方法,并找到了一些方法 (How to insert a picture into BLOB column in Oracle table using INSERT syntax?)。
我正在尝试在无法创建新表的环境中插入已在我的 oracle DB 中检索到的 blob。如何插入我拥有的这个 blob?我可以做一些事情来将我必须的 BLOB 转换为原始数据然后插入吗? 插入 TABLE 值 (1234,utl_raw.cast_to_raw(blob_data)) 数据不会被修改吗?谢谢!

【问题讨论】:

  • 如果您无法创建新表,您是否有任何具有 blob 列的现有表?您要将此 blob 插入哪种类型的列?
  • 我正在尝试将此 blob 插入到具有 blob 列的表中。

标签: oracle blob


【解决方案1】:

从您的问题来看,听起来您已经在数据库中有一个 blob,并且您想将它插入到表中。对于这个例子,假设它是这个空的 blob。

select empty_blob() as my_blob from dual;

您不需要进行任何转换;只需将其插入您的表格即可。

insert into MY_TABLE (example_column, blob_column) values 
  (1, (select empty_blob() as my_blob from dual) );

如果是 PL/SQL,那就更简洁了:

declare
  my_blob blob;
begin
  my_blob := empty_blob();
  insert into MY_TABLE (example_column, blob_column) 
    values (1, my_blob );
end;
/

如果您向我们提供有关如何检索和存储 blob 或表结构的详细信息,我们可能会提供更具体的答案。

【讨论】:

  • 我有 BLOB 作为我从数据库下载的文件,现在这个包含 Blob 的文件,我想插入到我的表中。
  • 所以您想将一个文件作为 blob 插入到您的表中?
  • 嗨,感谢@kfinity 抽出宝贵时间!我所做的是将 blob 文件转换为十六进制数据,并在插入语句中使用 Oracle SQL 的 hextoraw(...) 方法将数据插入我的数据库中。再次感谢!
猜你喜欢
  • 2019-06-09
  • 2020-06-13
  • 2022-01-20
  • 1970-01-01
  • 2015-01-01
  • 2014-04-27
  • 2013-11-02
  • 2019-11-06
  • 1970-01-01
相关资源
最近更新 更多