Press "Enter" to skip to content

How to Move File from One Directory to Another Using PL SQL

I am giving an example below to move a file from one directory to another using PL SQL in Oracle. To move a file from one location to another in Oracle, the database directory object for source directory and target directory must exist. If not then you must create to do this task.

Create the directory object for source location as shown below:

Create or Replace Directory source_file_dir as 'D:\text_files\';

Create the directory object for target location as shown below:

Create or Replace Directory target_file_dir as 'D:\text_files_2\';

Change path accordingly to yours and for Linux / Unix environments as well. Now run the procedure UTL_FILE.FRENAME to move the file as shown below:


The functionality of UTL_FILE.FRENAME procedure is similar to Unix mv command. It will remove the file from source directory after copying to the target directory. The complete usage syntax is below (Learn More…).

 src_location IN VARCHAR2,
 src_filename IN VARCHAR2, 
 dest_location IN VARCHAR2,
 dest_filename IN VARCHAR2,


Vinish Kapoor

I am a full stack developer and writing about development. I document everything I learn and help thousands of people. is created, written, and maintained by me, it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub and get notifications for new posts.

You may also like:

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *