如何使用Oracle PL SQL读取.sql/.txt文件?

发布于 2025-02-12 10:40:23 字数 161 浏览 0 评论 0原文

请您告诉我如何使用PL SQL阅读/解析SQL或文本文件! Objectif是我有一个包含关键词的文件,我想要的是PL SQL的过程,该过程可以读取该文件,并且在发现关键字的时刻执行特定函数。

PS:我认为“ dbms_sql.parse”不是这种情况的解决方案!

感谢你 :)

Please can you tell me how can i read/parse an sql or text file with pl sql !
the objectif is that i have a file containing key words and all i want is procedure with pl sql that can read that file and at the moment where the keyword is found it execute a specific function.

Ps: i don't think that "DBMS_SQL.PARSE" is the solution for this situation !

Thank u :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素年丶 2025-02-19 10:40:24

有几个选项,其中有以下几种:

  • 如果您创建外部表(基于该文件),则可以从SQL和PL/SQL访问它,就好像它是一个普通
  • ,或者,您可以编写PL/SQL过程并使用 utl_file 内置软件包来读取文件内容

这两个选项要求您可以访问A 目录,由特权用户创建和拥有的Oracle对象SYS,它将授予您(至少)读取特权(目录)。该目录指向包含文件的文件系统目录(文件夹);它通常位于数据库服务器上。如果您不是DBA(所以您不能自己做),那是一种缺点,并且没有DBA会为您做。


还有另一个选项 - 您可以将文件存储在您自己的PC上本地 - 是命令提示实用程序,名为 sql loader 。您要编写一个所谓的控制文件,该文件指示Oracle在哪里以及如何存储文件数据(在模式中的表中)。 SQL*加载程序与任何Oracle数据库一起安装;如果您的PC上没有任何内容,请检查客户端软件。

一旦将数据加载到表中,就可以对其进行任何操作。

There are several options, some of which are the following:

  • if you create an external table (based on that file), you'll be able to access it from both SQL and PL/SQL, as if it were an ordinary table
  • or, you can write a PL/SQL procedure and utilize the UTL_FILE built-in package to read file's contents

Both options require you to have access to a directory, an Oracle object created and owned by a privileged user, SYS, which will grant you (at least) read privileges on it (the directory). That directory points to a filesystem directory (folder) which contains the file; it is usually located on the database server. That's kind of a drawback if you aren't a DBA (so you can't do it yourself) and there's no DBA who will do it for you.


Yet another option - which lets you store the file locally, on your own PC - is the command prompt utility named SQL Loader. You'd write a so-called control file which instructs Oracle where and how to store file data (into a table in your schema). SQL*Loader is installed along with any Oracle database; if you don't have any on your PC, check the Client software.

Once you load data into the table, you can do whatever you want with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文