oracle xmltype

oracle 9i 以后是对xml做了支持的,先建立xmltype类型的字段
--创建xmltype 类型的表
create table xmlcontent (keyvalue varchar2(10) primary key,
                                       xmlvalue xmltype);
                   
--建立目录,如果不读文件可以不用
grant create any directory to snowhill;

select * from dba_directories    ;
create directory xmldir as 'd:\oracle\xml';      
--使用xmltype的静态方法createxml插入xml数据
INSERT INTO xmlcontent VALUES (2, XMLType.CreateXML(
       '<?xml version="1.0"?>
        <DATA>
           <name>Munising Falls</name>
           <county>Alger</county>
           <state>MI</state>
           <url>
              [url]http://michiganwaterfalls.com/munising_falls/munising_falls.html[/url]
           </url>
        </DATA>'));
       
       
INSERT INTO xmlcontent VALUES (1, XMLType.CreateXML(
       '<?xml version="1.0"?>
        <DATA>
           <name>snowhill.c</name>
           <county>china</county>
           <state>hubei</state>
           <url>
              http://www.blog.com/snowhill
           </url>
        </DATA>'));       
--检查节点是否存在
        select keyvalue  From xmlcontent  where existsNode(xmlvalue,'/DATA/url')>0
 --提取节点内容   
 select extractValue(xmlvalue, '/DATA/name')  from xmlcontent

posted on 2013-09-02 17:59 snowhill 阅读(268) 评论(0)  编辑 收藏 引用 所属分类: 数据库-oracle


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

导航

公告

又一年...........

留言簿(3)

随笔分类(13)

文章分类(131)

文章档案(124)

c++

java

linux

oracle

常用软件

其他

网络配置

系统安全

音乐

搜索

最新评论

阅读排行榜