oracle 如何将图片或图像插入oracle数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14435594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:47:29  来源:igfitidea点击:

how to insert picture or image into oracle database?

oracle

提问by Cool_Guy

<code>
 sql>CREATE TABLE Employees
     (
     Id int,
     Name varchar(50) not null,
     Photo varbinary(max) not null
     ) 
</code>

This code is showing error like this: photo varbinary(max) not null * ERROR at line 5: ORA-00907: missing right parenthesis Please help

此代码显示如下错误: photo varbinary(max) not null * ERROR at line 5: ORA-00907: missing right parenthesis 请帮忙

采纳答案by Rohit416

You should use BLOB (Binary Large Object)which is ideal for storing multimedia content like images.

您应该使用BLOB (Binary Large Object)它来存储图像等多媒体内容。

Check this out for storing images using BLOB.

检查这个以使用 BLOB 存储图像

回答by Dileep

You can create the table like below and insert into the table, below are the sample scripts for that

您可以创建如下表并插入到表中,下面是示例脚本

create table graphics_table (
  bfile_id number,
  bfile_desc varchar2(30),
  bfile_loc bfile,
  bfile_type varchar2(4));

INSERT INTO graphics_table
   VALUES(4,'April Book of Days Woodcut',bfilename('GIF_FILES','APRIL.JPG'),'JPEG');
INSERT INTO graphics_table
  VALUES(30,'',bfilename('GIF_FILES','SHAPIROS.GIF'),'GIF');

If u need more Info on this please refer to 

http://www.dba-oracle.com/t_storing_insert_photo_pictures_tables.htm

回答by Amaan Khan

First the question that has been posted is for SQL

首先,已发布的问题是针对 SQL

varbinary(max) is a new datatype in sql2012

varbinary(max) 是 sql2012 中的新数据类型

Cast f(x) will be used in order to convert the image into Binary format.

Cast f(x) 将用于将图像转换为二进制格式。

The insert query for the insertion of image is

插入图像的插入查询是

insert into Employees values(1, 'ABC', cast('path\abc.jpeg') as varbinary(max));

插入员工值(1, 'ABC', cast('path\abc.jpeg') as varbinary(max));