16.2 Creating a DBFS File System

A DBFS File system can be partitioned or non-partitioned.

16.2.1 Privileges Required to Create a DBFS File System

Database users must certain privileges to create a file system.

Following is the minimum set of privileges required for a database user to create a file system:

  • GRANT CONNECT
  • CREATE SESSION
  • RESOURCE, CREATE TABLE
  • CREATE PROCEDURE
  • DBFS_ROLE

16.2.2 Creating a Non-Partitioned File System

You can create a file system by running DBFS_CREATE_FILESYSTEM.SQL while logged in as a user with DBFS administrator privileges.

You can create a file system according to the following steps:

  1. Log in to the database instance:
    $ sqlplus dbfs_user/@db_server
    
  2. Enter the following command to create the filesystem. The tablespace in which the filesystem is created should be an ASSM tablespace to support SecureFile store
    @$ORACLE_HOME/rdbms/admin/dbfs_create_filesystem.sql tablespace_name
         file_system_name
    

For example, to create a file system called staging_area in an existing ASSM tablespace dbfs_tbspc:

$ sqlplus dbfs_user/db_server
   @$ORACLE_HOME/rdbms/admin/dbfs_create_filesystem.sql
   dbfs_tbspc staging_area

16.2.3 Creating a Partitioned File System

Files in DBFS are hash partitioned. Partitioning creates multiple physical segments in the database, and files are distributed randomly in these partitions.

You can create a partitioned file system by running DBFS_CREATE_FILESYSTEM_ADVANCED.SQL while logged in as a user with DBFS administrator privileges.

While creating a partitioned file system, you can specify any one of the following values as the hash key.

  • partition and partition-by-itemname: uses the item name as the partition key. The item name is the last component in the path name. Use this option to partition files based on the last component in the file path. For example, if /directory1/subdirectory2/filename.txt is the entire path, then filename.txt is the last component in the path and filename.txt is used as the partition key. If you use the partition option, then the file system is partitioned using the item name as the partition key.
  • partition-by-guid: uses the globally unique identifier (GUID) assigned to the file by DBFS as the partition key. DBFS assigns a GUID to each file. Use this option to partition the files based on the internally-generated GUID.
  • partition-by-path: uses the entire path of the file as the partition key. For example, if the file is /directory1/subdirectory2/filename.txt, then the entire /directory1/subdirectory2/filename.txt is considered as the partition key.
  1. Log in to the database instance:
    $ sqlplus dbfs_user/@db_server
    
  2. Enter one of the following commands to create the file system based on your requirement. The tablespace in which the file system is created should be an ASSM tablespace to support Securefile store.
    • Syntax

      @$ORACLE_HOME/rdbms/admin/dbfs_create_filesystem_advanced.sql tablespace_name
             file_system_name nocompress nodeduplicate noencrypt <partition | partition-by-itemname | partition-by-guid | partition-by-path>
      

      For example, to create a partitioned file system called staging_area in an existing ASSM tablespace dbfs_tbspc:

      $ sqlplus dbfs_user/@db_server  
             @$ORACLE_HOME/rdbms/admin/dbfs_create_filesystem_advanced.sql dbfs_tbspc
             staging_area nocompress nodeduplicate noencrypt partition
      

16.2.4 Dropping a File System

You can drop a file system by running DBFS_DROP_FILESYSTEM.SQL.

  1. Log in to the database instance:
    $ sqlplus dbfs_user/@db_server
    
  2. Enter the following command:
    @$ORACLE_HOME/rdbms/admin/dbfs_drop_filesystem.sql file_system_name