如何使用 Oracle 移动文本文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3529273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:19:35  来源:igfitidea点击:

How to move a text file using Oracle

oraclefileplsql

提问by Chicharito

I have two questions.

我有两个问题。

(1) how to make move text file from folder:

(1) 如何从文件夹中移动文本文件:

C:\Data\inbox\test.txt

to target Folder?

目标文件夹?

C:\Data\outbox\test.txt

(2) how to make get list of directory files in Folder?

(2) 如何获取文件夹中的目录文件列表?

C:\Data\inbox\

Thank you...

谢谢...

回答by APC

Oracle provides a package of utilities for working with files, UTL_FILE. Since 9i this has included the FRENAME() procedure, which works like the unix mvcommand. We can use it to rename the file and/or its directory. Note that the Oracle os account must have read and write privileges on both directories. Also this procedure uses DIRECTORY objects, rather than explicit paths.

Oracle 提供了一组用于处理文件的实用程序,UTL_FILE。从 9i 开始,这包括FRENAME() 过程,其工作方式类似于 unixmv命令。我们可以使用它来重命名文件和/或其目录。请注意,Oracle os 帐户必须对这两个目录具有读写权限。此外,此过程使用DIRECTORY 对象,而不是显式路径。

As for getting a list of files in a directory, there is no Oracle built-in. One solution is to use a Java Stored Procedure. Tom Kyte has an example of this. Find it here. There is another way of doing it since 11.1.0.7, which is to use an external table pre-processor file. Adrian Billington wrote a nice article on this. The executed file is platform dependent.

至于获取目录中的文件列表,Oracle 没有内置。一种解决方案是使用 Java 存储过程。Tom Kyte 有一个这样的例子。 在这里找到它。从 11.1.0.7 开始,还有另一种方法,即使用外部表预处理器文件。Adrian Billington在这方面了一篇不错的文章。执行的文件是平台相关的。

回答by Ian Carpenter

Where you say:

你说的地方:

2-) Question Two

Folder: C:\Data\inbox\

how to make get directory files list ?

2-) 问题二

文件夹:C:\Data\收件箱\

如何制作获取目录文件列表?

Tom Kyte has a nice solution shownhere

Tom Kyte在这里展示一个很好的解决方案

回答by Kamal Goduguluri

begin
  UTL_FILE.FCOPY (
   'EMPLOYEE'   , -- THIS IS A ORACLE DIRECTORY
   'EmpInfo.TXT'   , --FILE NAME
   'PROM_INCR'   , -- THIS IS A ORACLE DIRECTORY
   'EmpInfo.TXT' ); -- DESTINATION FILE
end;

try this

尝试这个