ORACLE DATABASE 12C: New Features for Oracle Database File System

Oracle Database File System (DBFS) was introduced in 11g R2 release on top of the XML DB (shortly, XDB) features.
The concept is simple: DBFS is a tablespace whose contents are documents (specifically LOB columns) directly accessible (i.e. mounted) as an external file system.
In Oracle 11g R2 the only way to do it is via FUSE (Filesystem in Userspace) software, only available for Linux and Solaris platforms. Moreover, the DBFS configuration and mount was a bit complex.
Oracle 12c introduces support for HTTP, FTP and WebDAV protocols, simplifying the setup process and widening its accessibility.
The DBFS creation process is the same in 11g R2 and 12c:
– Create a DBFS tablespace:
SQL> CREATE TABLESPACE dbfs_tbs
DATAFILE ‘/u01/app/oracle/oradata/DB12C/dbfs01.dbf’
SIZE 1M AUTOEXTEND ON NEXT 1M;
– Create a DBFS owner:
SQL> CREATE USER dbfs_user IDENTIFIED BY dbfs_user
DEFAULT TABLESPACE dbfs_tbs QUOTA UNLIMITED ON dbfs_tbs;
– Grant the necessary permissions, expecially the special DBFS_ROLE role:
SQL> GRANT CREATE SESSION, RESOURCE, DBFS_ROLE TO dbfs_user;
– Connect as DBFS owner and run the DBFS creation script:
SQL> CONNECT dbfs_user/dbfs_user
SQL> @?/rdbms/admin/dbfs_create_filesystem.sql dbfs_tbs orafs
No errors.
——–
CREATE STORE:
begin dbms_dbfs_sfs.createFilesystem(store_name => ‘orafs’, tbl_name => ‘orafs’, tbl_tbs => ‘dbfs_tbs’, lob_tbs => ‘dbfs_tbs’, do_partition => false, partition_key => 1, do_compress => false,
compression => ”, do_dedup => false, do_encrypt => false); end;
——–
REGISTER STORE:
begin dbms_dbfs_content.registerStore(store_name=> ‘orafs’, provider_name => ‘sample1’, provider_package => ‘dbms_dbfs_sfs’); end;
——–
MOUNT STORE:
begin dbms_dbfs_content.mountStore(store_name=>’orafs’, store_mount=>’orafs’); end;
——–
CHMOD STORE:
declare m integer; begin m := dbms_fuse.fs_chmod(‘/orafs’, 16895); end;
No errors.
The first parameter (dbfs_tbs) was the name of the DBFS tablespace, while the second (orafs) was the name of the new DBFS file system.
In order to access the newly created DBFS (in this example, /orafs) you can now setup one or more of these protocols:
HTTP OR WEBDAV
Verify if an HTTP port was already defined for XDB (it could be, as it is necessary for Enterprise Manager Express access):
SQL> SELECT DBMS_XDB_CONFIG.GETHTTPPORT FROM dual;
GETHTTPPORT
———–
If not, set it up:
SQL> EXEC DBMS_XDB_CONFIG.SETHTTPPORT(5500)
Now you can access the DBFS /orafs via HTTP using a borwser, for example:
http://ora12c:5500/dbfs/orafs
You can also access the DBFS via WebDAV, using for example MS Explorer (Windows systems) or Nautilus (for most Linux systems): simply add a Network Place in Windows or go to File -> Connect to server… in Nautilus.
WebDAV let you use drag-and-drop documents in the DBFS!
FTP
Verify if an FTP port was already defined for XDB, for example:
SQL> SELECT DBMS_XDB_CONFIG.GETFTPPORT FROM dual;
GETFTPPORT
———-
If not, set it up:
SQL> EXEC DBMS_XDB_CONFIG.SETFTPPORT(4021)
Now you can use any FTP Client to access documents and upload/download them to/from the FSDB.

You may also like...

Leave a Reply

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