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 的准确性,依赖于统计信息。

  • 相关阅读:
    mysql操作规范
    在线修改大表结构pt-online-schema-change
    MySQL 过滤复制
    IDEA “Cannot resolve symbol” 解决办法
    JAVA NIO Selector Channel
    Mysql二级索引
    技术选型关于redis客户端选择
    知乎上看到的一篇讲解Epoll的文章,较形象生动
    linux安装运行virtuoso数据库的详细过程
    go安装步骤(linux和Windows)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349461.html
Copyright © 2011-2022 走看看