Oracle11g R2学习系列 之八高级数据类型

所谓的高级数据类型,就是大数据类型,即BCNB(助记词:BC牛逼)+XML数据类型。

B:blob,用来存储可变长度的二进制数据。

C:clob,主要用来存储可变长度的字符型数据,也就是其他数据库中提到的文本型数据类型。

N:nclob,跟CLOB数据类型相似,也是用来存储字符类型的数据,不过其存储的是Unicode字符集的字符数据。

B:bfile,在数据库外面存储的可变二进制数据,最大可存储4G内容。

在dbms_lob包中内建了read()、append()、write()、erase()、copy()、getlength()、substr()等函数,可以方便地操作LOB对象

XML:xpath,xquery. 而xquery中最有特色的是FLWOR(发音同flower)表达式。FLWOR实际上是“For,Let,Where,Order by,Return”的缩写.包含模式匹配、过滤选择和结果构造这三种操作。感觉有点jquery的意味,选择,然后操作。只不守flwor似乎只有选择得到结果的意味。

 输入以下代码来体验一下flwor表达式,先创建一个有XMLType的表,然后插入一些数据,最后我想查询出第二条note的内容。

  create table table_notes(noteitem xmltype);
  
  insert into table_notes values('<notes>
    <note id="1">
      <to>wang</to>
      <from age="20">zhang</from>
      <heading>Reminder</heading>
      <body>Don not forget me this weekend!</body>
      <number>12</number>
  </note>
  <note id="2">
    <to>liu</to>
    <from age="30">li</from>
    <heading>Reminder</heading>
    <body>Don not forget me this weekend!</body>
    <number>12</number>
  </note>
</notes>');

select xmlquery('for $ageof in /notes/note
  where $ageof/@id="2"
  return string($ageof)'
  passing noteitem returning content) noteitem
from table_notes;
View Code

结果显示如下:

xquery

 

posted @ 2013-07-10 22:47  nateliu  阅读(449)  评论(0编辑  收藏  举报