What's the difference between a dba_tables and a dba_segments table block?

Source: Internet
Author: User
Tags commit

Oracle Table Blocks Test

To create a test table:

Sql> CREATE TABLE t5 (id int);

Table has been created.

Sql> INSERT INTO T5 values (1);

1 lines have been created.

Sql> INSERT INTO T5 values (2);

1 lines have been created.

Sql> INSERT INTO T5 values (3);

1 lines have been created.

Sql> INSERT INTO T5 values (4);

1 lines have been created.

Sql> commit;

Submit completed.

Insert a little more data:

Sql> begin

2 for I in 1 1000 loop

3 INSERT into T5 values (10000);

4 commit;

5 end Loop;

6 end;

7/

Analysis table

sql> Analyze table T5 compute statistics;

The table is parsed.

Description

Why collect statistics because the blocks in Dba_tables is only a value after collecting statistics, and for empty_blocks parameters, you must use analyze analysis to have a value. If you use Dbms_stats.gather_table_stats collection, only blocks values can be collected and empty_blocks not be collected.

This column more highlights: http://www.bianceng.cn/database/Oracle/

To view the blocks values in the dba_segments and Dba_tables tables:

Sql> Select Segment_name,blocks,extents,bytes,segment_type,tablespace_name from

dba_segments where segment_name= ' T5 ';

Segme BLOCKS extents BYTES segment_type tablespace_name

----- ---------- ---------- ---------- ------------------ ----------------------

T5 6528 53477376 TABLE SYSTEM

Sql> Select Blocks,empty_blocks from dba_tables where table_name = ' T5 ';

BLOCKS Empty_blocks

----------   ------------

6449 78

From the results above, we can see that:

6528 = 6449+78 +1

That

dba_segments. Blocks = Dba_tables.blocks+dba_tables.empty_blocks +1 (segment header block)

This extra 1 is the segment header block.

If the result of the query is not the case, you may not have an analytic table. You might as well analyze the table and check it out.

The two tables also have different definitions for blocks:

Dba_segments. BLOCKS holds the total number of BLOCKS allocated to the table.

User_tables. BLOCKS holds the total number of BLOCKS allocated for data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.