12C新特性:INMEMORY实战(4)启用IM虚拟列

启用IM虚拟列对应的参数为inmemory_virtual_columns,19C默认为MANUAL

SQL> show parameter INMEMORY_VIRTUAL_COLUMNS

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
inmemory_virtual_columns             string                            MANUAL

ENABLE:对于已在内存中启用的表或分区,所有虚拟列将以默认表或分区内存压缩级别存储在内存中。
MANUAL:这是参数的默认值。对于已启用内存存储的表或分区,除非存在以下情况,否则不会在内存中存储虚拟列:
它们已被明确标记为inmemory,在这种情况下,它们将被存储在表或分区内存压缩级别的内存中。
它们被标记为具有与基本表或分区不同的内存压缩级别的内存,在这种情况下,它们将以指定的内存压缩级别存储。
DISABLE:对于已在内存中启用的表或分区,将不会在内存中存储任何虚拟列。对于虚拟列的inmemory_column_clause的任何更改(包括memcompress级别的更改)都将被记录,但对于虚拟列的填充不起作用。

实验

创建虚拟列

SQL> ALTER TABLE test1 ADD (object_id_v AS (object_id*10));

Table altered.

查看当前test1的哪些列在的内存中

SQL> COL TABLE_NAME FORMAT a20
SQL> COL COLUMN_NAME FORMAT a20
SQL> 
SQL> SELECT TABLE_NAME, COLUMN_NAME, INMEMORY_COMPRESSION FROM   V$IM_COLUMN_LEVEL WHERE  TABLE_NAME = 'TEST1' ORDER BY COLUMN_NAME;

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                APPLICATION          DEFAULT
TEST1                CREATED              DEFAULT
TEST1                CREATED_APPID        DEFAULT
TEST1                CREATED_VSNID        DEFAULT
TEST1                DATA_OBJECT_ID       DEFAULT
TEST1                DEFAULT_COLLATION    DEFAULT
TEST1                DUPLICATED           DEFAULT
TEST1                EDITIONABLE          DEFAULT
TEST1                EDITION_NAME         DEFAULT
TEST1                GENERATED            DEFAULT
TEST1                LAST_DDL_TIME        DEFAULT

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                MODIFIED_APPID       DEFAULT
TEST1                MODIFIED_VSNID       DEFAULT
TEST1                NAMESPACE            DEFAULT
TEST1                OBJECT_ID            DEFAULT
TEST1                OBJECT_ID_V          NO INMEMORY    《==不在内存中
TEST1                OBJECT_NAME          DEFAULT
TEST1                OBJECT_TYPE          DEFAULT
TEST1                ORACLE_MAINTAINED    DEFAULT
TEST1                OWNER                DEFAULT
TEST1                SECONDARY            DEFAULT
TEST1                SHARDED              DEFAULT

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                SHARING              DEFAULT
TEST1                STATUS               DEFAULT
TEST1                SUBOBJECT_NAME       DEFAULT
TEST1                TEMPORARY            DEFAULT
TEST1                TIMESTAMP            DEFAULT

27 rows selected.

将虚拟列放入内存中

SQL>  ALTER TABLE test1 INMEMORY(object_id_v);

Table altered.

SQL> SELECT TABLE_NAME, COLUMN_NAME, INMEMORY_COMPRESSION FROM   V$IM_COLUMN_LEVEL WHERE  TABLE_NAME = 'TEST1' ORDER BY COLUMN_NAME;

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                APPLICATION          DEFAULT
TEST1                CREATED              DEFAULT
TEST1                CREATED_APPID        DEFAULT
TEST1                CREATED_VSNID        DEFAULT
TEST1                DATA_OBJECT_ID       DEFAULT
TEST1                DEFAULT_COLLATION    DEFAULT
TEST1                DUPLICATED           DEFAULT
TEST1                EDITIONABLE          DEFAULT
TEST1                EDITION_NAME         DEFAULT
TEST1                GENERATED            DEFAULT
TEST1                LAST_DDL_TIME        DEFAULT

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                MODIFIED_APPID       DEFAULT
TEST1                MODIFIED_VSNID       DEFAULT
TEST1                NAMESPACE            DEFAULT
TEST1                OBJECT_ID            DEFAULT
TEST1                OBJECT_ID_V          DEFAULT     《==在内存中
TEST1                OBJECT_NAME          DEFAULT
TEST1                OBJECT_TYPE          DEFAULT
TEST1                ORACLE_MAINTAINED    DEFAULT
TEST1                OWNER                DEFAULT
TEST1                SECONDARY            DEFAULT
TEST1                SHARDED              DEFAULT

TABLE_NAME           COLUMN_NAME          INMEMORY_COMPRESSION
-------------------- -------------------- --------------------
TEST1                SHARING              DEFAULT
TEST1                STATUS               DEFAULT
TEST1                SUBOBJECT_NAME       DEFAULT
TEST1                TEMPORARY            DEFAULT
TEST1                TIMESTAMP            DEFAULT

27 rows selected.

SQL> 

Related Posts