Utl_file.fopen in the utl_file package provided by Oracle is responsible for opening a file.
Utl_file.fopen (location in varchar2, filename in varchar2, open_mode in varchar2) return file_type;
Location is the path parameter,
Filename is the file name,
Open_mode is the open mode, 'R' is the read text, 'w' is the write text, and 'A' is the additional text. The parameter is case-insensitive. If 'A' is specified but the file does not exist, it is created with 'W', and 'w' has the overwriting function;
The location cannot be simply specified as a path such as 'd: \ Temp. You need to create a directory variable and pay the permission (you must Log On As A dBA ):
Create or replace directory d_output as 'd: \ Temp ';
Grant read, write on directory d_output to testdb;
Grant execute on utl_file to testdb;
Then you can use the utl_file package to create a file.
V_file utl_file.file_type;
V_file: = utl_file.fopen ('d _ output', 'data.txt ', 'w ');
You can create data.txt on the database server's D: \ temp.