HOW TO REMOVE AN OPERATING SYSTEM FILE FROM PL/SQL BLOCK
Directory Objects, Oracle Database, UTL_FILE
Removing an operating system file from a PL/SQL block.
GOAL
Removing an operating system file from a OS directory using the UTL_FILE package.
RELATED
HOW TO WRITE TO A FILE FROM PL/SQL BLOCK
HOW TO READ A FILE FROM PL/SQL BLOCK
HOW TO COPY AN OPERATING SYSTEM FILE FROM PL/SQL BLOCK
DEMO
The FREMOVE procedure of the UTL_FILE package deletes a disk file, assuming that you have sufficient privileges.
UTL_FILE.FREMOVE (
location IN VARCHAR2,
filename IN VARCHAR2);
location - Directory location of the file, a DIRECTORY_NAME from ALL_DIRECTORIES
filename - Name of the file to be deleted
NOTE
The file to be deleted was created in HOW TO COPY AN OPERATING SYSTEM FILE FROM PL/SQL BLOCK
## The file
ls -lh /tmp/dir2/myfile.cloned.txt --time-style='+'
-rw-r--r--. 1 oracle dba 32 /tmp/dir2/myfile.cloned.txt
-- Remove OS file
SET SERVEROUTPUT ON
BEGIN
UTL_FILE.FREMOVE('DIR2', 'myfile.cloned.txt');
END;
/
Confirm that file does not exist anymore
ls -lh /tmp/dir2/myfile.cloned.txt --time-style='+'
ls: cannot access /tmp/dir2/myfile.cloned.txt: No such file or directory
That's it. The file deleted.
Written At
04 JAN 202221:00
OEL Release
7.9 x64
Database Release
12.1.0.1.0 - 19.13.0.0.0
Tags In
Share
- Accounts
- Auditing
- AWR
- Bash Scripts
- Datapump
- Default Category
- Demos
- Directory Objects
- Environment Variables
- Initialization Parameters
- Iptables
- Java Program
- Memory Usage
- Metadata API
- Networker
- NLS Settings
- Optimizer Statistics
- ORA-00942
- ORA-01031
- ORA-01720
- ORA-28001
- ORA-31671
- Oracle Database
- Oracle Enterprise Manager
- Performance Tunning
- Postfix
- Privilegies
- Processes
- Queries
- Red Hat Enterprise Linux
- Redo Logs
- Session Tracing
- Sessions
- SQL Trace
- SQLPlus
- Statspack
- Tablespaces
- UTL_FILE
- UTL_FILE_DIR
- Wait Events
- Yum