Search code examples
oracle-databaseplsqlutl-file

PL/SQL - UTL_FILE physical location of the file


I want to use UTL_FILE pkg to read data from a csv file, I already have the code for it, but where exactly I should place the file?

I know that I need to give the path with the UTL_FILE.FOPEN, and I can also create a directory, but I can't find it after creating, so I can't put the file into that directory.

Could you please help me?

Thank you!


Solution

  • Usually:

    • SYSuser creates directory (Oracle object which points to a filesystem directory which resides on the database server
    • SYS also grants read and/or read privileges on that directory (Oracle object) to user(s) who will be using it, i.e. storing files in there
    • in order to be able to manipulate files on the operating system level, DBA grants you appropriate privileges on that filesystem directory. Otherwise, you won't be able to put files in there (such as your CSV file) nor get files you created using UTL_FILE

    When everything of above is done, then you'll be able to fully use the directory.

    Therefore: if you're not a DBA, you're probably in vain "creating directory" (as you said) because - if you were, you'd already know how it works. I suggest you talk to your DBA.