Professional Documents
Culture Documents
SecureFiles in Oracle 11g
SecureFiles in Oracle 11g
Table created.
SQL>
2
3
4
5
6
Table created.
Note: The tablespace where you are creating the securefile must be
Automatic Segment Space Management (ASSM) enabled, otherwise you
will meet with below error:
SQL>
2
3
4
Tablespace created.
SQL> CREATE TABLE secure_tab_ms(
2 id number,
3 myblob BLOB
4 )
5 LOB(myblob) store as securefile (tablespace mytbs1);
CREATE TABLE secure_tab_ms(
*
ERROR at line 1:
ORA-43853: SECUREFILE lobs cannot be used in non-ASSM tablespace "MYTBS1"
SEGMENT_NAME
BYTES
------------------------------ ---------SYS_LOB0000071365C00002$$
71303168
SYS_LOB0000071368C00002$$
9764864
LOB Compression
Anothjer useful feature of SecureFile is COMPRESS. This option of
SecureFiles enables compression of LOB contents at table or
partition level. The level of compression is indicated using the
optional MEDIUM and HIGH keywords. If no compression level is
specified, MEDIUM is used:
CREATE TABLE nocompress_tab (
id
NUMBER,
myblob CLOB
)
LOB(myblob) STORE AS SECUREFILE nocompress_lob(NOCOMPRESS tablespace
users);
CREATE TABLE compress_tab (
id
NUMBER,
myblob CLOB
)
LOB(myblob) STORE AS SECUREFILE (COMPRESS HIGH tablespace users);
DECLARE
l_blob CLOB := RPAD('X', 10000, 'X');
BEGIN
FOR i IN 1 .. 1000 LOOP
INSERT INTO nocompress_tab VALUES (i, l_blob);
END LOOP;
COMMIT;
FOR i IN 1 .. 1000 LOOP
INSERT INTO compress_tab VALUES (i, l_blob);
END LOOP;
COMMIT;
END;
SQL> select l.table_name, l.segment_name, s.bytes from dba_lobs l,
user_segments s where l.table_name IN ('COMPRESS_TAB', 'NOCOMPRESS_TAB')
AND S.SEGMENT_NAME = L.SEGMENT_NAME;
TABLE_NAME
SEGMENT_NAME
BYTES
------------------------------ ------------------------------ ---------NOCOMPRESS_TAB
SYS_LOB0000071389C00002$$
71303168
COMPRESS_TAB
SYS_LOB0000071385C00002$$
131072