暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 表上的高水印

askTom 2017-10-26
305

问题描述

嗨,汤姆,

如果我的删除查询没有删除任何记录,对HWM有影响吗?
我的意思是,一切都将与我的delete命令之前一样,请确认。

专家解答

即使您的删除确实删除了记录,也不会影响高水位线。

例如

SQL> create table t as select * from dba_objects;

Table created.

SQL> insert into t select * from t;

78473 rows created.

SQL> insert into t select * from t;

156946 rows created.

SQL> insert into t select * from t;

313892 rows created.

SQL> commit;

Commit complete.

SQL> execute dbms_stats.gather_table_stats('','T')

PL/SQL procedure successfully completed.

SQL>
SQL> select blocks from user_tables where table_name = 'T';

    BLOCKS
----------
     12171

1 row selected.

SQL> set autotrace on stat
SQL> select count(*) from t;

  COUNT(*)
----------
    627784

1 row selected.


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      12148  consistent gets
          0  physical reads
          0  redo size
        544  bytes sent via SQL*Net to client
        608  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> set autotrace off
SQL>
SQL> delete from t where rownum <= 200000;

200000 rows deleted.

SQL> commit;

Commit complete.

SQL>
SQL> execute dbms_stats.gather_table_stats('','T')

PL/SQL procedure successfully completed.

SQL>
SQL> select blocks from user_tables where table_name = 'T';

    BLOCKS
----------
     12171

1 row selected.

SQL> set autotrace on stat
SQL> select count(*) from t;

  COUNT(*)
----------
    427784

1 row selected.


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
      12148  consistent gets
          0  physical reads
          0  redo size
        544  bytes sent via SQL*Net to client
        608  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>
SQL>
复制


~ 12000块阅读,即使我删除了大部分记录。如果没有明确的动作 (收缩、移动等),高水位线不会降低
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论