SecureFiles is a completely new architecture inside the Oracle

Database 11g for handling file or unstructured data – word, pdf,
image, video and etc. Traditionally, we stored unstructured data in
data type of LOB/BLOB or in OS with reference to database. Before
Oracle 11g, there are many overheads if you store your unstructured
data in OS/LOB data type, like no smart backup mechanism, no storage
saving, no transaction/read consistency algorithm, no fine-grained
security control, no auditing and etc. In general: most of the
database features cannot be applied on it.
But now – with SecureFiles, the advanced features are available only
for SecureFiles and do not apply to older LOBs or BasicFiles. The
new features in SecureFiles - Deduplication, Compression and
Encryption - can be setup independently or as a combination of one
or more features.
Using SecureFiles:
First of all, there is a new initialization parameter enables DBA to
specify SecureFIles usage inside database. From doc:
Parameter Name: db_securefile
Parameter Type: text
Default Value: PERMITTED
Description: This parameter enables the database administrator to
either allow SECUREFILE LOBs to be created (PERMITTED), disallow
SECUREFILE LOBs from being created going forward (NEVER), force all
LOBs created going forward to be SECUREFILE LOBs (FORCE), attempt to
create SECUREFILE LOBs but fall back to BASICFILE LOBs (ALWAYS), or
disallow SECUREFILE LOBs and ignore any errors that would otherwise
be caused by forcing BASICFILE LOBs with SECUREFILE options
(IGNORE). Pls, read more details on this parameter from
Prior to Oracle 11g, we would have defined the table as follows:
CREATE TABLE basic_tab (
myblob BLOB
LOB(myblob)(tablespace users);

In Oracle 11g, as for backward compatibility, you would have define
it as below:
CREATE TABLE basic_tab (
myblob BLOB
LOB(myblob) store as basicfile (tablespace users);

as shown below: CREATE TABLE secure_tab ( id NUMBER. But with . This is possible in OS files but would not have been possible in Oracle Database 10g LOBs. deduplication is the most popular feature in SecureFiles. CREATE TABLE secure_tab_ms( * ERROR at line 1: ORA-43853: SECUREFILE lobs cannot be used in non-ASSM tablespace "MYTBS1" Your applications do not need to be changed in order to load data to SecureFile LOBs. all you have to do is place a clause "store as securefile" in the table creation. SQL> 2 3 4 5 6 CREATE TABLE secure_tab( id number. myblob BLOB ) LOB(myblob) STORE AS SECUREFILE (tablespace users). otherwise you will meet with below error: SQL> 2 3 4 CREATE TABLESPACE mytbs1 DATAFILE '/u01/app/oracle/oradata/ocmdb/mytbs01. Is it possible to store the BLOB only once and store only the reference to that copy on other 5 records. Note: The tablespace where you are creating the securefile must be Automatic Segment Space Management (ASSM) enabled. the same as you did for pre-11g LOB (BasicFile). myblob BLOB ) LOB(myblob) store as SECUREFILE (tablespace users) / Table created. it would reduce the space consumption.dbf' SIZE 10M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT MANUAL. 3 myblob BLOB 4 ) 5 LOB(myblob) store as securefile (tablespace mytbs1). Deduplication: In my opinion. myblob BLOB ) LOB(myblob) store as BASICFILE (tablespace users) / Table created. 6 of the BLOBs are identical. SQL> CREATE TABLE secure_tab_ms( 2 id number. SQL> 2 3 4 5 6 CREATE TABLE basic_tab ( id number. Tablespace created.If you want to store the LOB as a SecureFile. Imagine you have 10 records each with BLOB.

Table altered.table_name.---------SYS_LOB0000071365C00002$$ 71303168 SYS_LOB0000071368C00002$$ 9764864 . user_segments s where l.table_name IN ('DEDUPLICATE_TAB'. FOR i IN 1 . COMMIT. 10000. BEGIN FOR i IN 1 .segment_name. CREATE TABLE deduplicate_tab ( id NUMBER. user_segments s where l.SEGMENT_NAME = L. l. You can specify it during the table creation or modify it later. l. 'X'). another one with KEEP_DUPLICATES.SEGMENT_NAME.. s. Later. END LOOP. END. myblob CLOB ) LOB(myblob) STORE AS SECUREFILE (KEEP_DUPLICATES tablespace users). I will insert the same number of records to 2 tables: one with DEDUPLICATE option. END LOOP.-----KEEP_DUPLICATES_TAB SYS_LOB0000071365C00002$$ 71303168 DEDUPLICATE_TAB SYS_LOB0000071368C00002$$ 327680 You can also reverse the deduplication process: SQL> alter table deduplicate_tab modify lob(myblob) (keep_duplicates). COMMIT. TABLE_NAME SEGMENT_NAME BYTES -----------------------------. DECLARE l_blob CLOB := RPAD('X'. l_blob).table_name. l_blob).segment_name.. SQL> select l. Here. 1000 LOOP INSERT INTO deduplicate_tab VALUES (i. 1000 LOOP INSERT INTO keep_duplicates_tab VALUES (i. 'KEEP_DUPLICATES_TAB') AND S.SEGMENT_NAME.-----------------------------.bytes from dba_lobs l.SEGMENT_NAME = L.bytes from dba_lobs l. myblob CLOB ) LOB(myblob) STORE AS SECUREFILE (DEDUPLICATE tablespace users). s.SecureFiles it's actually trivial via a property called deduplication.table_name IN ('DEDUPLICATE_TAB'. we will see how much space used in each case: CREATE TABLE keep_duplicates_tab ( id NUMBER. TABLE_NAME -------------------------KEEP_DUPLICATES_TAB DEDUPLICATE_TAB SEGMENT_NAME BYTES -----------------------------. SQL> select l. 'KEEP_DUPLICATES_TAB') AND S.

s. If no compression level is specified. SQL> select l. CREATE TABLE compress_tab ( id NUMBER.table_name IN ('COMPRESS_TAB'. This option of SecureFiles enables compression of LOB contents at table or partition level.. 1000 LOOP INSERT INTO compress_tab VALUES (i.SEGMENT_NAME = L.segment_name. 'X'). 'NOCOMPRESS_TAB') AND S.-----------------------------.segment_name. 1000 LOOP INSERT INTO nocompress_tab VALUES (i.---------NOCOMPRESS_TAB SYS_LOB0000071389C00002$$ 71303168 COMPRESS_TAB SYS_LOB0000071385C00002$$ 131072 You can also reverse the compression process: ALTER TABLE compress_tab MODIFY LOB(myblob) (NOCOMPRESS). COMMIT. myblob CLOB ) LOB(myblob) STORE AS SECUREFILE nocompress_lob(NOCOMPRESS tablespace users).table_name IN ('COMPRESS_TAB'. user_segments s where l.table_name. The level of compression is indicated using the optional MEDIUM and HIGH keywords.SEGMENT_NAME. 10000. s.SEGMENT_NAME. l_blob). user_segments s where l. TABLE_NAME SEGMENT_NAME BYTES ------------------------.bytes from dba_lobs l. END LOOP. 'NOCOMPRESS_TAB') AND S. myblob CLOB ) LOB(myblob) STORE AS SECUREFILE (COMPRESS HIGH tablespace users). MEDIUM is used: CREATE TABLE nocompress_tab ( id NUMBER. l.---------NOCOMPRESS_TAB SYS_LOB0000071389C00002$$ 71303168 COMPRESS_TAB SYS_LOB0000071385C00002$$ 76808192 . END. SQL> select l. l. l_blob). COMMIT.SEGMENT_NAME = L..LOB Compression Anothjer useful feature of SecureFile is COMPRESS.bytes from dba_lobs l. END LOOP. TABLE_NAME SEGMENT_NAME BYTES -----------------------------. FOR i IN 1 . BEGIN FOR i IN 1 .-----------------------------. DECLARE l_blob CLOB := RPAD('X'.table_name.