zoukankan      html  css  js  c++  java
  • user_tables 的信息依赖于统计信息

    all_tables 描述当前用户访问的相关表:
    
    [oracle@node01 ~]$ sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on 星期四 10月 19 09:42:26 2017
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    连接到: 
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> create user tlcb identified by tlcb default tablespace users;
    
    用户已创建。
    
    SQL> grannt dba to tlcb;
    SP2-0734: 未知的命令开头 "grannt dba..." - 忽略了剩余的行。
    SQL> grant dba to tlcb;
    
    授权成功。
    
    
    SQL> create table test as select * from dba_objects;
    
    表已创建。
    
    
    SQL> select count(*) from test;
    
      COUNT(*)
    ----------
       1391440
    
    SQL> select a.TABLE_NAME,a.NUM_ROWS,a.LAST_ANALYZED  from user_tables a;
    
    TABLE_NAME			 NUM_ROWS LAST_ANALY
    ------------------------------ ---------- ----------
    TEST
    
    
    此时没有收集统计信息,没办法从user_tables中获取表的记录数信息
    
    
    对表进行统计信息收集
    
    BEGIN
      DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'TLCB',
                                    tabname          => 'TEST',
                                    estimate_percent => 100,
                                    method_opt       => 'for all columns size repeat',
                                    no_invalidate    => FALSE,
                                    degree           => 8,
                                    cascade          => TRUE);
    END;
    
    SQL>  select a.TABLE_NAME,a.NUM_ROWS,a.LAST_ANALYZED  from user_tables a;
    
    TABLE_NAME			 NUM_ROWS LAST_ANALY
    ------------------------------ ---------- ----------
    TEST				  1391440 2017-10-19
    
    SQL> select count(*) from TEST;
    
      COUNT(*)
    ----------
       1391440
    
    
    user_tables 的准确性,依赖于统计信息。

  • 相关阅读:
    1.常用命令
    虚拟机共享文件夹
    Docker安装 和简单使用
    js方法名通过参数传递调用实例
    highcharts参数说明
    绘制HightCharts饼状图
    附加数据库失败,操作系统错误 5:”5(拒绝访问。)”的解决办法
    ckeditor相关使用
    针对MySQL提高百万条数据的查询速度优化
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349461.html
Copyright © 2011-2022 走看看