首页  ·  知识 ·  
Label
      编辑:  图片来源:网络

ORACLE数据库记录应该如何才能输出到文本文件呢?下面就教您一个ORACLE数据库记录输出到文本文件的实现方法啊,希望对您学习ORACLE数据库记录方面能有所帮助。

在某些情况下,比如说为了与其他数据库进行数据交换,我们需要把ORACLE数据库里的数据输出来,保存到一个中间文件,然后再作处理。那么如何输出ORACLE数据库里的数据呢?

假设这些数据是文本类型的数据(字符、数字、日期),我们至少有两种办法输出,一种是利用制表功能,把所有数据以表格形式输出,并把表格保存到一个文本文件。另一种办法更简单,就是利用UTL_FILE包,直接把数据输入到文本文件。

在使用UTL_FILE包前需要在ORACLE数据库的初始化文件(initsid.ora)定义UTL_FILE的可写目录,例如

<ol class="dp-xml" style="font-size: 1.01em !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 3em !important; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 20px; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-image: url(http://www.51cto.com/images/art/images/010101bg.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; color: #000000; line-height: 30px; background-position: initial initial; background-repeat: no-repeat repeat; border: 0px none initial;"><li class="alt" style="font-size: 1.01em !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; list-style-type: decimal; list-style-position: outside !important; list-style-image: initial; color: inherit; line-height: 24px; background-image: url(http://www.51cto.com/images/art/AppData/Roaming/Adobe/Dreamweaver%20CS4/zh_CN/Configuration/images/dt1.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: no-repeat no-repeat; border: 0px none initial;"><span style="font-size: 1.01em !important; color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;"><span class="attribute" style="font-size: 1.01em !important; color: red; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">UTL_FILE</span><span style="font-size: 1.01em !important; color: black; background-color: inherit; padding: 0px; margin: 0px; border: 0px none initial;">=/eXPort/home/oracle/output </span></span></li></ol>
另外,还要注重的是输出记录中字段最大大小是1023字节,假如有字段超过这个限制,就需要把它截断成几部分,就如下面的例子一样。
这里给出一个实例,朋友们可以先照搬,然后根据自己数据库的实际情况,修改后使用。

<ol class="dp-xml" style="font-size: 1.01em !important; margin-top: 0px !important; margin-right: 0p

本文作者:网友 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读
也许感兴趣的
我们推荐的
主题最新
看看其它的
收藏至微信