oracle 如何测试Oracle目录的读/写文件系统权限?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9806677/
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-10 04:03:59  来源:igfitidea点击:

How to test read/write filesystem permissions of directory Oracle?

oraclepermissionsdirectory

提问by filippo

Say you create a directory like:

假设您创建了一个目录,例如:

CREATE OR REPLACE DIRECTORY 
EXT_DATA_FILES AS 
'/data/ext_data_files';
GRANT READ, WRITE ON DIRECTORY SYS.EXT_DATA_FILES TO MYAPPUSER;

I want to know if Oracle is capable of reading and writing files into that path. How could I test it?

我想知道 Oracle 是否能够在该路径中读取和写入文件。我怎么能测试呢?

That would help me a lot when creating external tables to avoid obscure error messages not really related to permissions error.

在创建外部表以避免与权限错误无关的模糊错误消息时,这对我有很大帮助。

回答by Justin Cave

You can use the UTL_FILEpackage. For example, this will verify that you can create a new file named some_new_file_name.txtin the directory and write data to it

您可以使用该UTL_FILE软件包。例如,这将验证您是否可以some_new_file_name.txt在目录中创建一个名为的新文件并向其中写入数据

DECLARE
  l_file utl_file.file_type;
BEGIN
  l_file := utl_file.fopen( 'EXT_DATA_FILES', 'some_new_file_name.txt', 'W' );
  utl_file.put_line( l_file, 'Here is some text' );
  utl_file.fclose( l_file );
END;

This will verify that a file named existing_file_name.txtexists and is readable

这将验证名为的文件existing_file_name.txt存在且可读

DECLARE
  l_exists     boolean;
  l_size       integer;
  l_block_size integer;
BEGIN
  utl_file.fgetattr( 'EXT_DATA_FILES', 
                     'existing_file_name.txt', 
                     l_exists, 
                     l_size, 
                     l_block_size );
   if( l_exists )
   then
     dbms_output.put_line( 'The file exists and has a size of ' || l_size );
   else
     dbms_output.put_line( 'The file does not exist or is not visible to Oracle' );
   end if;
END;

回答by Zack Macomber

You (or an admin) will have to login as oracle on the box to test that.

您(或管理员)必须以 oracle 身份登录到盒子上进行测试。

Or...just login as root and check the permissions on the directory. oracle's primary group at our shop is "oinstall". If the directory is not owned by oracle, you should make the group of the directory be oinstall.

或者...只需以 root 身份登录并检查目录的权限。oracle 在我们商店的主要群体是“oinstall”。如果目录不是oracle所有的,你应该将目录的组设置为oinstall。

I had a headache recently on getting permissions right in regards to external tables that I detailed here: sqlplus error on select from external table: ORA-29913: error in executing ODCIEXTTABLEOPEN callout

我最近在获取有关我在此处详述的外部表的权限方面感到头疼:从外部表中选择的 sqlplus 错误:ORA-29913:执行 ODCIEXTTABLEOPEN 标注时出错