--1.随机数
select dbms_random.value from dual;
select mod(dbms_random.random, 10) from dual;
--0-9随机数
select abs(mod(dbms_random.random, 10)) from dual;
--40-49随机数
select 40 + abs(mod(dbms_random.random, 10)) from dual;
 
--2.Xml
declare
       words clob;
       xmlStr varchar2(32767);
       line varchar2(2000);
       line_no number := 1;
begin
     words := dbms_xmlquery.getXML('select * from scott.emp');
     xmlStr := dbms_lob.substr(words, 32767);
     loop
         exit when (xmlStr is null);
         line := substr(xmlStr, 1, instr(xmlStr, chr(10)) - 1);
         dbms_output.put_line(line_no || ':' || line);
         xmlStr := substr(xmlStr, instr(xmlStr, chr(10)) + 1);
         line_no := line_no + 1;
     end loop;
end;
 
--3.文件
--定义文件夹 命名必须大写
create directory MY_DIR as 'D:\TEMP';
--读文件
declare
       inputfile UTL_FILE.file_type; --文件对象
       input varchar2(2000);
begin
     --指定文件
     --3个参数依次为:文件夹 文件 打开方式[r(读) w(写) a(追加)]
     inputfile := UTL_FILE.fopen('MY_DIR', 'demo.txt', 'r');
     loop              
         UTL_FILE.get_line(inputfile, input);
         dbms_output.put_line(input);             
     end loop;
     --关闭文件
     UTL_FILE.fclose(inputfile);
     exception
       when no_data_found then dbms_output.put_line('文件末尾!');
end;
 
--写文件
declare
       inputfile UTL_FILE.file_type; --文件对象
       input varchar2(2000) := 'Hello World!';
begin
     --指定文件
     --3个参数依次为:文件夹 文件 打开方式[r(读) w(写) a(追加)]
     inputfile := UTL_FILE.fopen('MY_DIR', 'mydemo.txt', 'a');
     --写入数据
     UTL_FILE.put_line(inputfile, input);
     --关闭文件
     UTL_FILE.fclose(inputfile);
     exception
       when no_data_found then dbms_output.put_line('文件末尾!');
end;

版权所有,转载请注明出处 本文出自: http://www.cnblogs.com/hoojo/archive/2011/05/03/2035427.html

oracle 查询XML操作、操作系统文件的更多相关文章

  1. XML DTD约束 对xml文件的crud的查询Read Retrieve操作 xml递归遍历

    本地的dtd文档 xml中引入dtd文档 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE 书 ...

  2. Oracle查询所有字段另加两个拼接字段的操作

    Oracle查询所有字段,再加两个字段拼接, select a.*,(SNO||SNAME) from TEST_STUDENT a; 同理,查询所有字段,其中两个字段求和:(SNO和SAGE都是NU ...

  3. 转--Oracle 审计和测试操作

    http://blog.itpub.net/21605631/viewspace-759640/转 Oracle 审计和测试操作 :: 分类: Linux 1.1 相关参数 AUDIT_SYS_OPE ...

  4. sql server中对xml进行操作

    一.前言 SQL Server 2005 引入了一种称为 XML 的本机数据类型.用户可以创建这样的表,它在关系列之外还有一个或多个 XML 类型的列:此外,还允许带有变量和参数.为了更好地支持 XM ...

  5. SQL Server 2008 对XML 数据类型操作

    原文 http://www.cnblogs.com/qinjian123/p/3240702.html 一.前言 从 SQL Server 2005 开始,就增加了 xml 字段类型,也就是说可以直接 ...

  6. Oracle日常运维操作总结-数据库的启动和关闭

    下面是工作中对Oracle日常管理操作的一些总结,都是一些基本的oracle操作和SQL语句写法,在此梳理成手册,希望能帮助到初学者(如有梳理不准确之处,希望指出). 一.数据库的启动和关闭 1.1 ...

  7. Oracle.DataAccess.dll方式操作oracle数据库

    Oracle.DataAccess.dll方式操作oracle数据库 一.查询语句: using (OracleConnection conn = new OracleConnection(Syste ...

  8. Oracle.ManagedDataAccess.dll方式操作oracle数据库

    Oracle.ManagedDataAccess.dll方式操作oracle数据库 一.查询语句: using (OracleConnection conn = new OracleConnectio ...

  9. c#对xml的操作

    操作xml可以通过XElement对象,比较方便的使用列举以下几点: 把字符串转变成XElement,保存成xml文件,加载xml文件: //把字符串解析成XElement对象 string str ...

随机推荐

  1. 多线程资源隔离之ThreadLocal

    上篇讲到多线程线程安全问题的解决思路,这篇将详细讲解资源隔离ThreadLocal的实践. ThreadLocal也叫线程局部变量,类似Map结构,以当前线程为key.既然是以资源隔离的思想保证线程安 ...

  2. docker 修改 mysql 5.7 sql_mode

    docker exec -ti {容器ID} /bin/bash   进入容器 apt-get install vim 安装vim 找到 vim /etc/mysql/my.cnf 在 [mysqld ...

  3. ubuntu安装python MySQLdb模块

    本文讲述了python安装mysql-python的方法.分享给大家供大家参考,具体如下: ubuntu 系统下进行的操作 首先安装了pip工具 ? 1 sudo apt-get install py ...

  4. 正则表达式-RegExp-常用正则表达式

    正则表达式-RegExp-常用正则表达式   作者:nuysoft/JS攻城师/高云 QQ:47214707 EMail:nuysoft@gmail.com 声明:本文为原创文章,如需转载,请注明来源 ...

  5. MySQL级联删除和级联修改

    1.新建主键table create table demo1_zhujian ( id int primary key auto_increment, name )); 2.新建外键table cre ...

  6. Python 实现C语言 while(scanf("%d%d", &a, &b) != EOF) 语句功能

    reference:Python 实现C语言 while(scanf("%d%d", &a, &b) != EOF) 语句功能 在python中,无法通过input ...

  7. Object.defineProperties——MEAN开发后台的Model层

    Object.defineProperties是什么?有什么用? 这个问题比较听起来可能比较难以理解,确实我也是在项目中遇到的才会去想.以前看到<高级程序设计>的时候,有这么一种东西,定义 ...

  8. C# 自动触发鼠标、键盘事件

    要在C#程序中触发鼠标.键盘事件必须要调用windows函数. 一.鼠标事件的触发 1.引用windows函数mouse_event /// <summary> /// 鼠标事件 /// ...

  9. css 固定宽度,自动换行

    max-width: 200px; display: block; word-break: break-all:

  10. [spring]Bean注入——使用注解代替xml配置

    使用注解编程,主要是为了替代xml文件,使开发更加快速. 一.使用注解前提: <?xml version="1.0" encoding="UTF-8"?& ...