如何测试目录Oracle的读/写文件系统权限? [英] How to test read/write filesystem permissions of directory Oracle?
问题描述
说你创建一个目录,如:
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;
我想知道Oracle是否能够将文件读入和写入该路径。如何测试?
I want to know if Oracle is capable of reading and writing files into that path. How could I test it?
在创建外部表时,这将帮助我很多,以避免与权限错误无关的模糊错误消息。
That would help me a lot when creating external tables to avoid obscure error messages not really related to permissions error.
推荐答案
您可以使用 UTL_FILE
包。例如,这将验证您可以在目录中创建名为 some_new_file_name.txt
的新文件,并将数据写入
You can use the UTL_FILE
package. For example, this will verify that you can create a new file named some_new_file_name.txt
in the directory and write data to it
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;
这将验证名为 existing_file_name.txt的文件
存在且可读
This will verify that a file named existing_file_name.txt
exists and is readable
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;
这篇关于如何测试目录Oracle的读/写文件系统权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!