• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

TRUNCATE TABLE not releasing space from tablespace

by admin

When we delete the rows from the table using the DELETE command, the extents that are allocated to the table will not be released and the table still holds them, whereas when using TRUNCATE with DROP STORAGE clause (which is the default), it will release the space back to the tablespace.

But we see cases that event truncating won’t release the space back to the tablespace.

The answer is simple, When a truncate is issued on a table, Oracle deallocates all space used by the removed rows except that specified by the MINEXTENTS storage parameter. However, if the minextent (along with the initial value) is large enough, this space is NOT released even after the truncate.

For example, see a table in my case which is of 586 MB in size

CREATE TABLE XYZ
( COL1 VARCHAR2(45 BYTE),
COL2 VARCHAR2(45 BYTE),
COL3 VARCHAR2(6 BYTE) )
TABLESPACE XYZ_DATA
RESULT_CACHE (MODE DEFAULT)
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 100M
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;

From the above, we can see that the initial extent size itself is 100M. If we truncate this table which is having a total size of 586 MB, Oracle will de-allocate only 486 MB and will keep that 100 MB attached to the table.

1. export the table to save the data.

2. drop the table and recreate it with a small INITIAL size.

3. import the data back.

Filed Under: oracle

Some more articles you might also be interested in …

  1. Archived Redo File Conventions in Oracle RAC
  2. How to Disable Oracle Net Tracing without stopping server process
  3. When to Use Startup/Shutdown Database and Alter Database Command in Oracle 12c
  4. How To Setup UDEV Rules For RAC OCR And Voting Devices on Partitions
  5. How do we Set A Retention Policy For Tape Backups And Disk Backups Differently
  6. Transaction Control Statement Examples in SQL
  7. Oracle Database 18c: Roll Forward Physical Standby Using RMAN Incremental Backup in Single Command
  8. ORA-27125: unable to create shared memory segment; Error: 28: No space left on device
  9. How To Run ggsci In “silent” Mode
  10. How to Change the Default Home Page of Oracle HTTP Server

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright