Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • scripts to take listener.log backup Linux/Unix
  • How to sort list of files on basis of their sizes. Linux/Unix
  • Windows based Command line mailing program like mailx (Sednmail for windows) PHP/MYSQL/Wordpress
  • Session_info.ksh Linux/Unix
  • find_du.ksh to find # of files, their sizes in current folder and its subdolder Linux/Unix
  • Useful Solaris Commands on 28-SEP-2005 Linux/Unix
  • Pending Distributed Transations Oracle
  • rm_backup_arch_file.ksh Linux/Unix
  • db_status.sql Oracle
  • PLSQL Table Syntax 2 Oracle
  • USER_TABLES.Freelists Oracle
  • Finding last recovered file on DR and remove all chanracters before any “/” Linux/Unix
  • scripts to take listener.log backup Linux/Unix
  • moving lob object to other tablespace lob_mvmt.sql Oracle
  • Create type and Grant on it. Oracle

How to Decide upto what level you can decrement your datafile size. ( Shrink Datafile)

Posted on 12-Jun-2006 By Admin No Comments on How to Decide upto what level you can decrement your datafile size. ( Shrink Datafile)

We can directly resize datafiles

TEST.SQL>SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_NAME BYTES

—————- ———-

/…/dbsGNX.dbf 419430400

TEST.SQL>ALTER DATABASE DATAFILE ‘/…/dbsGNX.dbf’ RESIZE 390M;

Database altered.

TEST.SQL>SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_NAME BYTES

————— ———-

/…/dbsGNX.dbf 408944640

But the minimum file size is the size of the extend the furthest in the datafile:

TEST.SQL>SELECT FILE_ID,FILE_NAME FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_ID FILE_NAME

———- —————–

1 /…/dbsGNX.dbf

TEST.SQL>SELECT MAX(BLOCK_ID) MBID FROM DBA_EXTENTS WHERE FILE_ID=1;

MBID

———-

25129

TEST.SQL>SELECT SEGMENT_NAME,OWNER,SEGMENT_TYPE FROM DBA_EXTENTS WHERE FILE_ID=1 AND BLOCK_ID=25129;

SEGMENT_NAME OWNER SEGMENT_TYPE

——————– —————————— ——————

I_OBJAUTH2 SYS INDEX

TEST.SQL>SHOW PARAMETER BLOCK_SIZE

NAME TYPE VALUE

———————————— ——————————– ——————————

db_block_size integer 8192

TEST.SQL>SELECT 8192*25129 FROM DUAL;

8192*25129

———-

205856768

about 200M.

We can directly resize datafiles

TEST.SQL>SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_NAME BYTES

—————– ———-

/…/dbsGNX.dbf 419430400

TEST.SQL>ALTER DATABASE DATAFILE ‘/…/dbsGNX.dbf’ RESIZE 390M;

Database altered.

TEST.SQL>SELECT FILE_NAME, BYTES FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_NAME BYTES

—————- ———-

/…/dbsGNX.dbf 408944640

But the minimum file size is the size of the extend the furthest in the datafile:

TEST.SQL>SELECT FILE_ID,FILE_NAME FROM DBA_DATA_FILES WHERE TABLESPACE_NAME=’SYSTEM’;

FILE_ID FILE_NAME

———- ————————-

1 /…/dbsGNX.dbf

TEST.SQL>SELECT MAX(BLOCK_ID) MBID FROM DBA_EXTENTS WHERE FILE_ID=1;

MBID

———-

25129

TEST.SQL>SELECT SEGMENT_NAME,OWNER,SEGMENT_TYPE FROM DBA_EXTENTS WHERE FILE_ID=1 AND BLOCK_ID=25129;

SEGMENT_NAME OWNER SEGMENT_TYPE

——————— —————————— ——————

I_OBJAUTH2 SYS INDEX

TEST.SQL>SHOW PARAMETER BLOCK_SIZE

NAME TYPE VALUE

———————————— ——————————– ——————————

db_block_size integer 8192

TEST.SQL>SELECT 8192*25129 FROM DUAL;

8192*25129

———-

205856768

About 200M.

Reference : http://forums.oracle.com/forums/message.jspa?messageID=1058350

Oracle, SQL scripts

Post navigation

Previous Post: How to find the real execution plan and binds used in that explain plan in Oracle 10g??
Next Post: How to find Unix server conguraiton including Server Model number and underlying disk sub-system ( On Solaris)

Related Posts

  • How to calculate PROCESSES parameter Oracle
  • Find Stale DR Physical Standby Oracle
  • Find Plan Hash value fphv.sql Oracle
  • RMAN : Consistent Backup, Restore and Recovery using RMAN Oracle
  • Find Multiple levels of object dependencies : depen.sql Oracle
  • Recovering lost SYS password Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (395)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (343)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025
  • Postgres DB user and OS user.25-Dec-2025
  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Oracle Statspack survival Guide Oracle
  • FGA Part-I Oracle
  • How to find the real execution plan and binds used in that explain plan in Oracle 10g?? Oracle
  • CTAS with LONG Column for 7.x and 8 and 8i Oracle
  • Handling LOB data in Oracle Oracle
  • Python class import from different folders Python/PySpark
  • Rman Notes -1 Oracle
  • Find all users who have DML privileges Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme