oracle xmltype简介
找不到原帖了 就贴这里吧!
在向大家详细介绍Oracle之前,首先让大家了解下Oracle xmltype是什么,Oracle从9i开始支持一种新的数据类型----
xmltype,用于存储和管理xml数据,并提供了很多的functions,用来直接读取xml文档和管理节点。下面将介绍Oracle
xmltype的一些基本使用。
1.建立含有Oracle xmltype数据类型的表create table abc (id number,xmldoc
sys.xmltype);声明xmltype型字段用:sys.xmltype。
2.向带有xmltype类型的表插入带有数据insert into abc (id,xmldoc) value (abc.nextval ,
sys.xmlType.createXML(''<name><a id="1" value="some
values">abc</a></name>'') );插入用
sys.xmlType.createXML(''some xml doc'')
3.直接查询Oracle xmltype字段里面的内容得到id=1的value变脸的值select
i.xmldoc.extract(''//name/a[@id=1]/@value'').getStringVal() as ennames,
id from abc i得到a节点的值select id,
i.xmldoc.extract(''//name/a/text()'').getStringVal() as truename from
abc i得到节点id属性的值Select
hd.Data_t.extract(''/root/name/@id'').getStringVal() As Name from
sehr_house_data hd
4.更新Oracle xmltype里面的数据update abc set
xmldoc=updateXML(xmldoc,''//name/a[@id=1]/@value'',''some new value'')
where ......(注意:如果里面没有<a id="1">这个节点,将不能update)
5.添加超过4k字节的xml文档到xmltype型字段可以通过使用临时表的办法实现:
◆先建立一个临时的表,其中的一个字段是clob
类型;
◆再将要写入xmltype字段的xml doc写入这个临时的clob型的字段中;
◆最后insert into abc
(id,xmldoc) values (abc_q.nextval , sys.xmlType.createXML((select
content from 临时表 where id=......)));
相关文档:
import Java.io.*;
import java.util.*;
import java.sql.*;
public class LobPros
{
/**
* Oracle驱动程序
*/
private static final String DRIVER = "oracle.jdbc.driver.OracleDriver";
/**
* ORACLE连接用URL
*/
p ......
---------数学函数
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.取整(截取)
S:select cast(-1.002 as int) v ......
We are pleased to announce that Oracle has completed its acquisition of Sun Microsystems and Sun is now a wholly owned subsidiary of Oracle. With this news, we want to reiterate our commitment to deliver complete, open and integrated systems that help our customers improve the performance, reliabi ......
录oracle数据库时常用的操作命令整理
1、su – oracle 不是必需,适合于没有DBA密码时使用,可以不用密码来进入sqlplus界面。
2、sqlplus /nolog 或sqlplus system/manager 或./sqlplus system/manager@ora9i;
3、SQL>connect / as sysdba ;(as sysoper)或
connect internal/oracle AS SYSDBA ;(scott/tiger) ......