oracle表注释与查询提示(result_cache_mode)的关系

1、result_cache_mode比表注释优先使用的情况。

create table test_Result_cache (id number) result_cache (mode default);

mode default这个值仅移除任何已经设置的表注释,并不允许包含这张表的查询结果进行缓存。

SQL> select t.table_name,t.result_cache from user_Tables t where t.table_name=‘TEST_RESULT_CACHE‘ ;
 
TABLE_NAME                                                                       RESULT_CACHE
-------------------------------------------------------------------------------- ------------
TEST_RESULT_CACHE                                                                DEFAULT

上面创建表的语句与下面创建表的语句其作用是一样的。

create table test_Result_cache (id number)

下面查看一下相关结果集缓存参数的设置

SQL> show parameter result_cache;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_lag              big integer 3000
client_result_cache_size             big integer 0
result_cache_max_result              integer     5
result_cache_max_size                big integer 4608K
result_cache_mode                    string      MANUAL
result_cache_remote_expiration       integer     0

这时需要对结果集进行缓存可以使用查询提示,如下

select /*+result_cache*/* from test_Result_cache

可以通过下面方式查看结果集是否成功缓存

SQL> select id,name,value from v$result_cache_statistics;
 
        ID NAME                                                                             VALUE
---------- -------------------------------------------------------------------------------- ---------------------------------------------------         1 Block Size (Bytes)                                                               1024
         2 Block Count Maximum                                                         4608
         3 Block Count Current                                                              32
         4 Result Size Maximum (Blocks)                                             230
         5 Create Count Success                                                           5
         6 Create Count Failure                                                             0
         7 Find Count                                                                               0
         8 Invalidation Count                                                                   0
         9 Delete Count Invalid                                                                 0
        10 Delete Count Valid                                                                  0
        11 Hash Chain Length                                                                1
        12 Find Copy Count                                                                      0
        13 Latch (Share)                                                                            0

Create Count Success:表示成功缓存结果集的数量。

2、result_cache_mode比表注释优先使用的情况二。

alter table test_result_cache result_cache(mode force);

这时确保result_cache_mode的值为MANUAL

SQL> show parameter result_cache_mode;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
result_cache_mode                    string      MANUAL

清空结果集缓存中的数据。

SQL> exec dbms_result_cache.Flush;
 
PL/SQL procedure successfully completed

SQL> select id,name,value from v$result_cache_statistics;
 
        ID NAME                                                                             VALUE
---------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
         1 Block Size (Bytes)                                                               1024
         2 Block Count Maximum                                                              4608
         3 Block Count Current                                                              0
         4 Result Size Maximum (Blocks)                                                     230
         5 Create Count Success                                                             0
         6 Create Count Failure                                                             0
         7 Find Count                                                                       0
         8 Invalidation Count                                                               0
         9 Delete Count Invalid                                                             0
        10 Delete Count Valid                                                               0
        11 Hash Chain Length                                                                0
        12 Find Copy Count                                                                  0
        13 Latch (Share)                                                                    0

通过下面的语句测试情况

SQL> select /*+no_result_cache*/* from test_Result_cache;

执行计划
----------------------------------------------------------
Plan hash value: 5006760

---------------------------------------------------------------------------------------
| Id  | Operation         | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |                   |     2 |    26 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| TEST_RESULT_CACHE |     2 |    26 |     3   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)

从上面的查看结果中看出,查询并没有的使用结果集缓存中的内容。也可以直接查询相关的视图

SQL> select id,name,value from v$result_cache_statistics;
 
        ID NAME                                                                             VALUE
---------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
         1 Block Size (Bytes)                                                               1024
         2 Block Count Maximum                                                              4608
         3 Block Count Current                                                              0
         4 Result Size Maximum (Blocks)                                                     230
         5 Create Count Success                                                             0
         6 Create Count Failure                                                             0
         7 Find Count                                                                       0
         8 Invalidation Count                                                               0
         9 Delete Count Invalid                                                             0
        10 Delete Count Valid                                                               0
        11 Hash Chain Length                                                                0
        12 Find Copy Count                                                                  0
        13 Latch (Share)                                                                    0

其结果也是一样。

3、表注释优先于result_cache_mode的情况。

alter table test_result_cache result_cache(mode force);

这时可以查看一下result_cache_mode的值

SQL> show parameter result_cache_mode;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
result_cache_mode                    string      MANUAL

这时通过下面的查询会直接读取结果集缓存中的数据

SQL> select * from test_Result_cache;

执行计划
----------------------------------------------------------
Plan hash value: 5006760

-------------------------------------------------------------------------------------------------
| Id  | Operation          | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |                            |     2 |    26 |     3   (0)| 00:00:01 |
|   1 |  RESULT CACHE      | 5z4pvwymt41zz4hjnb3pwvcfuy |       |       |            |          |
|   2 |   TABLE ACCESS FULL| TEST_RESULT_CACHE          |     2 |    26 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------

Result Cache Information (identified by operation id):
------------------------------------------------------

1 - column-count=1; dependencies=(DESIGNER.TEST_RESULT_CACHE); name="select * from test_Result_cache"

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)

也可以直接查看缓存结果集的数量

SQL> select id,name,value from v$result_cache_statistics;
 
        ID NAME                                                                             VALUE
---------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
         1 Block Size (Bytes)                                                               1024
         2 Block Count Maximum                                                              4608
         3 Block Count Current                                                              32
         4 Result Size Maximum (Blocks)                                                     230
         5 Create Count Success                                                             6
         6 Create Count Failure                                                             0
         7 Find Count                                                                       0
         8 Invalidation Count                                                               1
         9 Delete Count Invalid                                                             0
        10 Delete Count Valid                                                               0
        11 Hash Chain Length                                                                1
        12 Find Copy Count                                                                  0
        13 Latch (Share)                                                                    0

时间: 2024-12-26 02:43:31

oracle表注释与查询提示(result_cache_mode)的关系的相关文章

oracle表空间使用率查询

sqlplus -s / as sysdba<<EOFset trimspool onset linesize 10000set pagesize 50000set heading onset term offset heading onset feedback off;set newp none;set echo offset markup html onspool onspool xj.xls--表空间使用率查询: select t.tablespace_name,t.total,f.fr

Oracle 表空间和数据文件之间的关系

首先,你需要明白的一点是:数据库的物理结构是由数据库的操作系统文件所决定,每一个Oracle数据库是由三种类型的文件组成:数据文件.日志文件和控制文件.数据库的文件为数据库信息提供真正的物理存储. 每一个Oracle数据库有一个或多个物理的数据文件(data file).一个数据库的数据文件包含全部数据库数据.逻辑数据库结构(如表.索引等)的数据物理地存储在数据库的数据文件中.数据文件通常为*.dbf格式,例如:userCIMS.dbf.数据文件有下列特征:①.一个数据文件仅与一个数据库联系:②

CodeSmith无法获取Oracle表注释

如题:安装CodeSmith5.2版本,SQLServer没有任何问题,而Oracle就只能获取列的注释而不能获取表的注释,经过多方面查找资料后找到了一个最重要的解决方案,Sql语句,如下:select * from user_tab_comments这句Sql语句的作用就是查询系统中所有表的注释,而我们只需要加入条件就可以查询到注释,代码如下: //获得表的注释,Oracle专用 public string GetTableDescription(){ string result=""

ORACLE 表空间使用率查询

SELECT A.TABLESPACE_NAME, A.BYTES / (1024 * 1024 * 1024 ) TOTAL, B.BYTES / (1024 * 1024 * 1024 ) USED, C.BYTES / (1024 * 1024 * 1024 ) FREE, (B.BYTES * 100 ) / A.BYTES "% USED", (C.BYTES * 100 ) / A.BYTES "% FREE" FROM SYS.SM$TS_AVAIL

六分钟学会创建Oracle表空间的步骤

经过长时间学习创建Oracle表空间,于是和大家分享一下,看完本文你肯定有不少收获,希望本文能教会你更多东西. 1.先查询空闲空间 select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space; 2.增加Oracle表空间 先查询数据文件名称.大小和路径的信息,语句如下: select tablespace_name,file_id,bytes,file_name from dba_data_files; 3.修

1.Oracle表的DDL实践

1.Oracle表的DDL实践. 设有如下关系表S_班名座号(如:s_xg140101): s_ xg140101 (SNO, SNAME, SSEX, SAGE, SDEPT),主关键字是SNO. 其中SNO为学号,NUMBER(5),学号不能为空,值是惟一的:SNAME为姓名,VARCHAR2(20):SSEX为性别,char(2):SAGE为年龄,NUMBER(2):SDEPT为所在系名,VARCHAR2(10).写出实现下列功能的SQL语句. 1.1 创建此表并插入数据: Create

2015-10-19 SQL(新建数据库、创建表、注释、查询语句、新增、更新、删除、联合查询)

1.认识数据库并新建: 1)打开数据库,连接到服务器. 2)服务里类型不用管. 3)服务器名称:打个点“.”表示服务器在本地计算机,如果是托管在别人的服务器上,就输入服务器IP地址. 4)身份验证:如果是windows身份验证,就需要有管理员权限.一般托管在别人的服务器上,(包括正常情况下),都是用SQL身份验证,需要输入sa和密码(密码就是安装时让输入的密码). 2.  建立数据库: 在建立数据库名称时(各种名称时),都遵守一个命名规则: 1)用英文命名 2)每个单词的首字母大写(驼峰原则:首

Oracle EBS-SQL (SYS-7):表单个性化查询.sql

animation-timing-function animation-timing-function 规定动画的速度曲线.速度曲线定义动画从一套 CSS 样式变为另一套所用的时间.在平常的取值中,主要有以下几个: 值 描述 linear 动画从头到尾的速度是相同的. ease 默认.动画以低速开始,然后加快,在结束前变慢. ease-in 动画以低速开始. ease-out 动画以低速结束. ease-in-out 动画以低速开始和结束. cubic-bezier(n,n,n,n) 在 cub

【Oracle 常用查询】oracle表空间使用率统计查询

参考1 --查询表空间使用情况 SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)", D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)", To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), '990.99') || '