Home > oracle > Next Extent Size Is Reset after Truncate

Next Extent Size Is Reset after Truncate

March 2nd, 2008

You can alter table’s next extent size in DMT tablespace.

But if the table has already allocated old size extents. The next extent size will be reset after truncate.

See below:

First, create a table in DMT tablespace with 5M next extent size.

  1. SQL> create table tt(x int) tablespace CSHAN_TEST storage(initial 5M next 5M pctincrease 0);
  2.  
  3. Table created.
  4.  
  5. SQL> alter table tt allocate extent;
  6.  
  7. Table altered.
  8.  
  9. SQL> /
  10.  
  11. Table altered.
  12.  
  13. SQL> /
  14.  
  15. Table altered.
  16.  
  17. SQL> /
  18.  
  19. Table altered.
  20.  
  21. SQL> /
  22.  
  23. Table altered.
  24.  
  25. SQL> /
  26.  
  27. Table altered.

  1. SQL> select initial_extent,next_extent from dba_tables where table_name='TT' and owner='SYS';
  2.  
  3. INITIAL_EXTENT NEXT_EXTENT
  4. -------------- -----------
  5.        5242880     5242880
  6.  
  7. SQL> select extent_id,bytes from dba_extents where segment_name='TT' and owner='SYS';
  8.  
  9.  EXTENT_ID      BYTES
  10. ---------- ----------
  11.          0    5242880
  12.          1    5242880
  13.          2    5242880
  14.          3    5242880
  15.          4    5242880
  16.          5    5242880
  17.          6    5242880
  18.          7    5242880
  19.          8    5242880
  20.          9    5242880
  21.         10    5242880
  22.         11    5242880
  23.         12    5242880
  24.         13    5242880
  25.         14    5242880
  26.         15    5242880
  27.  
  28. 16 rows selected.

Then alter table’s next extent size to 10M.

  1. SQL> alter table tt storage(next 10M);
  2.  
  3. Table altered.
  4.  
  5. SQLalter table tt allocate extent;
  6.  
  7. Table altered.
  8.  
  9. SQL> select extent_id,bytes from dba_extents where segment_name='TT' and owner='SYS';
  10.  
  11.  EXTENT_ID      BYTES
  12. ---------- ----------
  13.          0    5242880
  14.          1    5242880
  15.          2    5242880
  16.          3    5242880
  17.          4    5242880
  18.          5    5242880
  19.          6    5242880
  20.          7    5242880
  21.          8    5242880
  22.          9    5242880
  23.         10    5242880
  24.         11    5242880
  25.         12    5242880
  26.         13    5242880
  27.         14    5242880
  28.         15    5242880
  29.         16    5242880
  30.         17   10485760
  31.  
  32. 18 rows selected.
  33.  
  34. SQL> select initial_extent,next_extent from dba_tables where table_name='TT' and owner='SYS';
  35.  
  36. INITIAL_EXTENT NEXT_EXTENT
  37. -------------- -----------
  38.        5242880    10485760

Truncate table:

  1. SQL> truncate table tt;
  2.  
  3. Table truncated.

You can see the table’s next extent size goes back to 5M.

  1. SQL> select initial_extent,next_extent from dba_tables where table_name='TT' and owner='SYS';
  2.  
  3. INITIAL_EXTENT NEXT_EXTENT
  4. -------------- -----------
  5.        5242880     5242880
  6.  
  7. SQL> alter table tt allocate extent;
  8.  
  9. Table altered.
  10.  
  11. SQL> select extent_id,bytes from dba_extents where segment_name='TT' and owner='SYS';
  12.  
  13.  EXTENT_ID      BYTES
  14. ---------- ----------
  15.          0    5242880
  16.          1    5242880
  17.          2    5242880
  18.          3    5242880
  19.          4    5242880
  20.          5    5242880
  21.          6    5242880
  22.          7    5242880
  23.          8    5242880
  24.          9    5242880
  25.         10    5242880
  26.  
  27. 11 rows selected.

Eagle Fan oracle

  1. August 5th, 2009 at 14:45 | #1

    Добавлю в избранное, написано не плохо

  1. No trackbacks yet.