Heim  >  Artikel  >  Datenbank  >  Oracle二进制类型和大对象类型基础

Oracle二进制类型和大对象类型基础

WBOY
WBOYOriginal
2016-06-07 15:44:331258Durchsuche

参考资料 1.Oracle Concepts Oracle DataType中对数据类型的介绍: http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i4146 2.Oracle JDBC Developer Guid 1】work with oracle object type中对对象数据类型在java中的get和set的介绍:

参考资料 

1.Oracle Concepts Oracle DataType中对数据类型的介绍: http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i4146 

2.Oracle JDBC Developer Guid 

  1】work with oracle object type中对对象数据类型在java中的get和set的介绍: http://docs.oracle.com/cd/B28359_01/java.111/b31224/oraoot.htm#autoId0

  2】java stream in JDBC 中对二进制类型通过java获取流然后在os文件系统生成文件的方法介绍。 http://docs.oracle.com/cd/B28359_01/java.111/b31224/jstreams.htm#i1014109 

3.Oracle JDBC API 各数据类型的API介绍: http://download.oracle.com/otn_hosted_doc/jdeveloper/905/jdbc-javadoc/index.html?oracle/sql/NCLOB.html 

一、类型区分 

Long 存储变长的字符数据(2G,向后兼容,不建议使用)

NCLOB 存储单字节的字符数据(4G)

CLOB 存储多字节的字符数据(4G)

BFILE 存储OS文件系统中的二进制文件的指针,文件不存储在数据库里。所以当你将文件插入把BFile字段以后,如果你将电脑中的这个文件删除或者移动存储目录,那么从这个字段就找不到存储的这个文件了。264 - 1 bytes

BLOB 存储二进制数据(4G) 

RAW 存储定长二进制数据(2000byte),需要定义长度,如:create table t(s raw(2000); 

LONG RAW 存储可变长二进制数据(2G,Oracle已不建议使用)。

二、类型在数据库中的使用 

NCLOB 

?

1

2

3

4

5

6

create table t(id int,cont NCLOB); 

Insert into t(id,cont) values(1,’hello’); 

select from t; 

ID CONT 

------------------------- 

1 hello

CLOB 同NCLOB。

BLOB 暂未找到能直接插入的值的方法。

BFILE 

?

1

2

3

4

5

6

7

8

9

10

Conn lyy/lyy 

Create table bfiletable(id int,obj BFILE); 

Create or replace directory dir AS ‘d:\’; 

Conn / as sysdba 

Grant read directpry dir to lyy; 

Conn lyy/lyy Insert into bfiletable(id,obj) values(1,filename(‘DIR’,’1.jpg’)); 

Select from filetable; 

ID OBJ 

------------------------------------------------- 

1 filename(‘DIR’,’1.JPG’)

RAW  

?

1

2

3

4

5

6

Create table rawtable(id int,obj raw(2000)); 

Insert into rawtable(id,obj) values(1, uti_raw.cast_to_raw(‘hello’)); 

Select from rawtable; 

ID OBJ 

 -------------------------------------------------

 1 68656C6C6F

LONG RAW 

?

1

2

3

4

5

6

Create table lrawtable(id int,obj long raw); 

Insert into lrawtable(id,obj) values(1, uti_raw.cast_to_raw(‘hello’)); 

Select from lrawtable; 

ID OBJ 

------------------------------------------------- 

1 6

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn