Access Network File System from Autonomous Database
You can attach a Network File System to a directory location in your Autonomous Database.
This allows you to load data from Oracle Cloud Infrastructure File Storage in your Virtual Cloud Network (VCN) or from any other Network File System in on-premises data centers.
-
Connect to an Autonomous Database instance from a legacy application and use the file system to load and unload data.
-
Analyze data from different sources in an Autonomous Database.
-
Secure access to data in an Autonomous Database from the file systems in an on-premises data center or Private Virtual Cloud Networks (VCNs).
Attach Network File System to Autonomous Database
Use DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM
to attach a file system to a
directory in your Autonomous Database.
Note:
TheDBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM
procedure can only attach a private
File Storage Service to databases that are on private endpoints.
To access data in an Autonomous Database from the file systems in an on-premises data center you must set up FastConnect or a Site-to-Site VPN to connect to the on-premises data center. See FastConnect and Site-to-Site VPN for more information.
After you attach a file system you can query the
DBA_CLOUD_FILE_SYSTEMS
view to retrieve information about the attached
file system.
For example:
SELECT file_system_name, file_system_location, directory_path
FROM dba_cloud_file_systems
WHERE file_system_name = 'FSS';
This query returns details for the FSS
file system name.
See DBA_CLOUD_FILE_SYSTEMS View for more information.
With an attached file system you can read and write to files on an attached file system using any PL/SQL API that accepts a directory name. For example, you can use any of the following methods to work with an attached NFS directory:
-
The
UTL_FILE
package. -
Data Pump Export and Import utilities.
-
The
DBMS_CLOUD
APIs that work with directories such asDBMS_CLOUD.LIST_FILES
andDBMS_CLOUD.PUT_OBJECT
.
Example showing a write a file on an attached file system using
UTL_FILE
:
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_location VARCHAR2(100) := 'FSS_DIR';
l_filename VARCHAR2(100) := 'test.csv';
BEGIN
-- Open the file.
l_file := UTL_FILE.FOPEN(l_location, l_filename, 'w');
UTL_FILE.PUT(l_file, 'Scott, male, 1000');
-- Close the file.
UTL_FILE.FCLOSE(l_file);
END;
/
Example showing a read a file on an attached file system using
UTL_FILE
:
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_location VARCHAR2(100) := 'FSS_DIR';
l_filename VARCHAR2(100) := 'test.csv';
l_text VARCHAR2(32767);
BEGIN
-- Open the file.
l_file := UTL_FILE.FOPEN(l_location, l_filename, 'r');
UTL_FILE.GET_LINE(l_file, l_text, 32767);
-- Close the file.
UTL_FILE.FCLOSE(l_file);
END;
/
Example showing list files on an attached file system using DBMS_CLOUD.LIST_FILES
:
SELECT object_name FROM DBMS_CLOUD.LIST_FILES
('FSS_DIR');
Notes for using DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM
:
-
Oracle Cloud Infrastructure File Storage uses NFS Version 3 to share
- If you attach to non-Oracle Cloud Infrastructure File Storage systems, the procedure supports NFS Version 2 and NFS Version 3
-
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM
does not support NFS Version 4
Detach Network File System from Autonomous Database
Use the DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM
procedure to detach a file system
from a directory in your Autonomous Database.
Note:
TheDBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM
procedure can only detach a private
File Storage Service from the databases that are on private endpoints.
You must have the WRITE
privilege on the directory object to
detach a file system from a directory location.
Run DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM
procedure to detach a file
system from a directory location in your Autonomous Database. To run this procedure, you must be logged in as the ADMIN user or have the
EXECUTE
privilege on DBMS_CLOUD_ADMIN
.
BEGIN
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM
(
file_system_name => 'FSS'
);
END;
/
This example detaches the network file system specified in the
file_system_name
parameter from the Autonomous Database. You must provide a value for this parameter.
The information about this file system is removed from the
DBA_CLOUD_FILE_SYSTEMS
view.
DBA_CLOUD_FILE_SYSTEMS View
The DBA_CLOUD_FILE_SYSTEMS
view lists the
information about the network file system attached to a directory location in the
database.
Column | Description |
---|---|
FILE_SYSTEM_NAME |
File system name |
FILE_SYSTEM_LOCATION |
File system location |
DIRECTORY_NAME |
Attached directory name |
DIRECTORY_PATH |
Attached directory path |
DESCRIPTION |
The value provided for the description parameter when you run |
CREATION_TIME |
Creation timestamp |