Skip to Main Content
  • Questions
  • UTL_FILE write and User permission in Unix directory


Question and Answer

Connor McDonald

Thanks for the question, Muthukumaran.

Asked: March 27, 2020 - 10:44 am UTC

Answered by: Connor McDonald - Last updated: March 30, 2020 - 1:16 am UTC

Category: PL/SQL - Version: Oracle 12c

Viewed 100+ times

You Asked

I am using UTL_FILE.FOPEN('Unix_Directory_path','FileName.txt','w') in my Pl/Sql package and the file is getting written successfully but the User and permission are different than the file generated using SPOOL, both are using the same batch file in UNIX

-rw-r----- 1 explora exploit 15975 Mar 27 17:32 SPOOL_Test_20200229.txt_bk
-rw-r--r-- 1 oracle exploit 15975 Mar 27 18:26 UTL_FILE_Test_20200229.txt

The first file which is created with explora USER but the UTL_FILE creates the file using Oracle USER, Is there any way to create the file with explora USER ?

and we said...

Sorry no, because UTL_FILE is running *as* the oracle user.

You could consider using 'umask' to make the group read/write ...but anything that relaxes security permissions must always be treated with care.

More to Explore


Check out more PL/SQL tutorials on our LiveSQL tool.