17.2 Creating a DBFS File System
You can create a partitioned or non-partitioned DBFS File system.
For both partitioned and non-partitioned DBFS, you can specify one or more of the following storage properties to specify how your files are stored in DBFS: compression and deduplication.
For example, you can configure DBFS as a compressed file system with partitioning. At the time of creating a DBFS file system, you must specify the set of features that you want to enable for the file system.
After creating a DBFS, you can track the usage of the DBFS. If you want to change the storage properties of the DBFS, you can reorganize the DBFS. You can update the metadata of the DBFS by changing the values for parameters, such as deduplicate
, compress
, and partition
. For example, you may have created a DBFS to store all the files in the compressed format. If you want to change this property, you can reorganize the DBFS.
- About the Create File System Command
Use this command to quickly create, register, and mount a file system. - Privileges Required to Create a DBFS File System
Database users must certain privileges to create a file system. - Creating a Non-Partitioned File System
You can create a file system by runningDBFS_CREATE_FILESYSTEM.SQL
while logged in as a user with DBFS administrator privileges. - 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. - Enabling Advanced SecureFiles LOB Features for DBFS
Using the@dbfs_create_filesystem.sql
command, you can create a partitioned or non-partitioned file system with the compression and deduplicate options. If you want to specify additional options while creating the file system, use theDBMS_DBFS_SFS.CREATEFILESYSTEM
procedure.
Parent topic: Using DBFS
17.2.1 About the Create File System Command
Use this command to quickly create, register, and mount a file system.
Syntax
$ sqlplus @dbfs_create_filesystem.sql tablespace_name file_system_name [compress-high | compress-medium | compress-low | nocompress] [deduplicate | nodeduplicate] [partition | non-partition | partition-by-itemname | partition-by-guid | partition-by-path]
Where the mandatory parameters are:
tablespace_name
is the tablespace in which you want to create a file system.file_system_name
is the unique name of the file system that you want to create.
The optional parameters are:
compress
: when you use this option DBFS compresses the files, and then stores the files. Use this option to reduce the storage space consumed by the files. Note that it takes more time to read and write to compressed files as the files have to be decompressed before you can read or write to the file.You can specify one of the following options:
compress
,compress-high
,compress-medium
,compress-low
. When you specifycompress
orcompress-medium
, the compression level is medium.Generally, the compression level
compress-low
performs best and still provides a good compression ratio. Compression levelscompress-high
andcompress-medium
provide significantly better compression ratios, but compression times can be correspondingly longer. Oracle recommends using NONE or LOW when write performance is critical, such as when files in the DBFS store are updated frequently. If space is critical and the best possible compression ratio is desired, usecompress-high
orcompress-medium
. Files are compressed as they are paged out of the cache into the staging area. Therefore, compression also benefits by storing smaller files in the staging area and effectively increasing the total available capacity of the staging area.If you don't specify any option to compress the files,
nocompress
is the default value.deduplicate
: when you use this option, DBFS maintains a single copy of the file to save storage space even if you have multiple copies of the file in different folders. Let's consider that 100 users in an e-commerce company require access to the postal zip codes. Using deduplication, even if all 100 users store the file in different folders, the DBFS maintains a single copy of the file that contains the postal ZIP codes and the DBFS doesn't store multiple copies of the file. The reduction of duplication saves space. If user A updates the file containing postal zip codes, the updated file is stored as a separate copy in the DBFS. The next time user A wants to access the file, user A is pointed to the updated copy of the file while the remaining users are still pointed to the original file. Note that it takes more time to update and write to the DBFS when you use the deduplicate option.nodeduplicate
is the default value.partition
: use this option to create a partitioned file system, and then specify any one of the following values as the hash key.partition
andpartition-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, thenfilename.txt
is the last component in the path andfilename.txt
is used as the partition key. If you use thepartition
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.
If you specify only the
partition
option, then it defaults topartition-by-itemname
, where item name refers to the name of the file or directory.
Using the @dbfs_create_filesystem.sql
command, you can create a file system with the options described in this section. If you want to specify additional options while creating the file system, you can use the DBMS_DBFS_SFS.CREATEFILESYSTEM
procedure.
See Also:
- CREATEFILESYSTEM Procedure in PL/SQL Packages and Types Reference.
- Persistent LOBs and Creating a Partitioned File System for more information about the features of SecureFiles LOBs.
Parent topic: Creating a DBFS File System
17.2.2 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
Parent topic: Creating a DBFS File System
17.2.3 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.
Before you begin, ensure that you create the file system in an ASSM tablespace to support SecureFile store. For information about creating an ASSM tablespace, see Creating a SecureFiles File System Store.
To create a non-partitioned file system:
Parent topic: Creating a DBFS File System
17.2.4 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
.SQL
while logged in as a user with DBFS administrator privileges.
The tablespace in which you create the file system should be an ASSM tablespace to support Securefile store. Before you begin, ensure that you create the file system in an ASSM tablespace to support SecureFile store. For information about creating an ASSM tablespace, see Creating a SecureFiles File System Store.
Parent topic: Creating a DBFS File System
17.2.5 Enabling Advanced SecureFiles LOB Features for DBFS
Using the @dbfs_create_filesystem.sql
command, you can create a partitioned or non-partitioned file system with the compression and deduplicate options. If you want to specify additional options while creating the file system, use the DBMS_DBFS_SFS.CREATEFILESYSTEM
procedure.
For information about all the additional options that you can use with the DBMS_DBFS_SFS.CREATEFILESYSTEM
procedure, see CREATEFILESYSTEM Procedure in PL/SQL Packages and Types Reference.
Use the @dbfs_create_filesystem.sql
command to quickly create, register, and mount a file system. When you use the DBMS_DBFS_SFS.CREATEFILESYSTEM
procedure to enable additional options while creating a file system, you must additionally run commands to register and mount the file system that you create.
Let's use the DBMS_DBFS_SFS.CREATEFILESYSTEM
procedure to create a file system with the encryption option.
Before you begin, ensure that you have created a wallet with the encryption key. See Administer Key Management in SQL Language Reference.
To create a file system with the encryption option:
- Run the following command.
Syntax
exec dbms_dbfs_sfs.createFilesystem('store_name',tbl_tbs=>'tablespace_name',do_encrypt=> true | false,encryption=> encryption_type, do_dedup=> true | false,do_compress=>true | false);
For reference information about the command options, see CREATEFILESYSTEM Procedure in PL/SQL Packages and Types Reference.
Example
For example, to create a file system in
Test3
store in thetest_fs1
tablespace with the default encryption, compression, and deduplicate options:exec dbms_dbfs_sfs.createFilesystem('test_fs1', tbl_tbs=>'Test3', do_encrypt=>true, encryption=>dbms_dbfs_sfs.ENCRYPTION_DEFAULT, do_dedup=>true, do_compress=>true);
The file system is created with the option you have specified.
-
Run the following command to register the file system that you have created.
Syntax
dbms_dbfs_content.registerStore(store_name => 'filesystem_name', provider_name => 'posix',provider_package => 'dbms_dbfs_sfs') ;
Example
For example, run the following command to register the
test_fs1
file system.dbms_dbfs_content.registerStore(store_name => 'test_fs1', provider_name => 'posix', provider_package => 'dbms_dbfs_sfs') ;
-
Run the following command to mount the file system that you have created.
Syntax
dbms_dbfs_content.mountStore(store_name => 'filesystem_name', store_mount => 'filesystem_name');
Example
For example, run the following command to mount the
test_fs1
file system.dbms_dbfs_content.mountStore(store_name => 'test_fs1', store_mount => 'test_fs1');
Parent topic: Creating a DBFS File System