简体   繁体   English

如何在Oracle查询中禁用PL / SQL

[英]How to disable PL/SQL in Oracle queries

Here's an example of the sort of query I would like to prevent from running on my server: 这是我想阻止在我的服务器上运行的那种查询的示例:

begin
  While True
  LOOP
     dbms_output.put_line('tst');
  END LOOP;
end

This query (or others like it) may be hitting my Oracle server via the Oracle JDBC thin driver. 此查询(或其他类似的查询)可能通过Oracle JDBC瘦驱动程序访问我的Oracle服务器。 I would be open to preventing this query from running either at the JDBC configuration level, the database server configuration level, or via user permissions within the schema. 我愿意阻止此查询在JDBC配置级别,数据库服务器配置级别或通过架构中的用户权限运行。 I would like the user to continue to be able to run normal select/insert/update/delete queries. 我希望用户能够继续运行正常的select / insert / update / delete查询。 Honestly I'd be quite happy if none of the PL/SQL type commands were available, and instead only standard SQL. 老实说,如果没有PL / SQL类型命令可用,我会很高兴,而只是标准SQL。

Update 更新

I should also mention that I want users to continue to be able to use standard functions in their SQL queries. 我还要提一下,我希望用户能够继续在SQL查询中使用标准函数。 I just really don't want them doing anything that looks like procedural programming (and having to worry about the pitfalls of such things, as seen above). 我真的不希望他们做任何看起来像程序编程的事情(并且不得不担心这些事情的陷阱,如上所示)。

You can't prevent people from writing procedural PL/SQL code against your server. 您无法阻止人们针对您的服务器编写程序性PL / SQL代码。 Depending on the exact nature of the problem you're trying to solve, however, you may have other options. 但是,根据您尝试解决的问题的确切性质,您可能还有其他选择。 Two options that spring to mind... 两个选项让人想起......

You can create a profile associated with the database user that enforces various resource limits. 您可以创建与数据库用户关联的配置文件 ,以强制执行各种资源限制。 So you can limit the amount of CPU a single call can consume or the number of reads it can do. 因此,您可以限制单个调用可以消耗的CPU量或它可以执行的读取次数。 That lets you automatically kill sessions that do something like coding an infinite loop. 这使您可以自动终止执行类似无限循环编码的会话。 Note that the RESOURCE_LIMIT initialization parameter needs to be set to TRUE in order for Oracle to enforce resource limits in profiles. 请注意, RESOURCE_LIMIT初始化参数需要设置为TRUE,以便Oracle在配置文件中强制执行资源限制。

You can use Oracle Resource Manager to prioritize access to resources to reduce the risk that a developer's mistake will take all the resources available on the server and starve the important production processes. 您可以使用Oracle Resource Manager来优先访问资源,以降低开发人员的错误将占用服务器上所有可用资源并使重要生产流程匮乏的风险。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM