Shrink Datafile Size!

Dear All,
My database server 11gR1 is running on Linux operating system. The disk where my database exists is almost 80% used. I need to shrink datafile, is there any such option available.
When i take dump of my database it is like 3.5 GB but the database size shown in the space summary of oracle enterprise manager is like 22 GB while the tablespace shows only 20% free space in it.
What is the best possible way to perform this function? Kindly help me. If there is anything else you need to know kindly ask.
Regards, Imran Baig

Identify which tablespace has grown big.
It could be the tablespace which hold application tables or undo datafiles or temp datafiles.
If it is the tablespace which hold the application data, find which object is big (from dba_segments).
It could be like some table is created with 15Gb storage space and contain only 1Gb of data.
SQL> set serveroutput on
SQL> set pages 1000
SQL> set lines 160
SQL> DECLARE
  2      alc_bks     NUMBER;
  3      alc_bts     NUMBER;
  4      unsd_bks    NUMBER;
  5      unsd_bts    NUMBER;
  6      luefi       NUMBER;
  7      luebi       NUMBER;
  8      lub         NUMBER;
  9  BEGIN
10          DBMS_SPACE.UNUSED_SPACE (
11              segment_owner               => 'RNCRY'
12          ,   segment_name                => 'COMS'
13          ,   segment_type                => 'TABLE'
14          ,   total_blocks                => alc_bks
15          ,   total_bytes                 => alc_bts
16          ,   unused_blocks               => unsd_bks
17          ,   unused_bytes                => unsd_bts
18          ,   last_used_extent_file_id    => luefi
19          ,   last_used_extent_block_id   => luebi
20          ,   last_used_block             => lub
21          );
22
23  DBMS_OUTPUT.PUT_LINE('Allocated space = '|| alc_bts );
24  DBMS_OUTPUT.PUT_LINE('Actual used space = '|| unsd_bts );
25  EXCEPTION
26      WHEN OTHERS THEN
27          DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,250));
28  END;
29  /
Allocated space = 8534360064
Actual used space = 46874624
PL/SQL procedure successfully completed.The COMS table was allocated around 8Gb but it has only 44Mb of data.
So in this case the space is wasted and you cannot resize the datafile as the space is already allocated to a table.
Identify these kind of objects and then either you can use the SHRINK SPACE command or re create the object with
only required storage space.
If all the the objects are small, then you should be able to resize the datafiles using the RESIZE command.
HTH

Similar Messages

  • How to shrink the system tablespace datafile Size

    iam using oracle 9i R2 and i want to reduce my datafile size but it's show's that error when i try to resize it. ORA-03297

    Hi,
    We can directly resize datafilesTEST.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
    408944640But 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
    205856768about 200M.
    Regards,
    Yoann.

  • To shrink the size of TEMP tablespace

    Dear all,
    There is a databse with RAC, now in OEM the size of TEMP tablespace has been reached at 99.9%. now we want to shrink the size of TEMP tablespace.
    how to we do that???????
    plz help me...........

    Temporary tablespaces usually show they are full, however this space is not actually in use. It is rather allocated. Oracle has evaluated the best way to obtain the most of performance, and he said it is better to allocate once than allocate-deallocate-reallocate extents, so temporary space is not 'released'.
    If you want to feel psychologically more confortable with lower allocated space, you can drop your tablespace (create an interim default temporary tablespace first) and recreate it.
    You can also rebuild temporary datafiles:
    alter tablespace temp add tempfile 'C:\ORACLE\ORACLEXE\ORADATA\XE\TEMP01.dbf' size 32m;
    SQL> select name from v$tempfile;
    NAME
    C:\ORACLE\ORACLEXE\ORADATA\XE\TEMP.DBF
    C:\ORACLE\ORACLEXE\ORADATA\XE\TEMP01.DBF
    SQL> alter database tempfile 'C:\ORACLE\ORACLEXE\ORADATA\XE\TEMP01.DBF' drop including datafiles;
    Database altered.

  • Shrink Datafiles for database in Avalability Group

    We're running SharePoint 2010 on SQL Server 2012.   We are also using Availability Groups for all databases (Primary and Secondary replica).   I'm running low on space and would like to shrink the datafiles for one of the content
    databases.  The content database has 2 datafiles spread across 2 LUNS.  The SharePoint content database had a run away situation that caused the database to grow very large.  The situation has been corrected and the database now has about 98%
    free space.  The database will not grow much larger than it is now.  I know shrinking datafiles is generally not a good idea, but in the case I think it's appropriate.
    My question is, has anyone done this before on a database/datafiles that are in a High Availability Group?  Are there any risks?  Any recommendations?
    Thanks!

    Hi,
    SharePoint content database is different than the ordinary database . You need to test the effect in the test environment before making the changes to the product environment.
    There is a good article regarding Database Maintenance for SharePoint
    http://technet.microsoft.com/en-us/library/cc262731(v=office.14).aspx#DBMaintenanceForSPS2010_ShrinkingDataFiles
    Only perform shrink operations rarely, and only after you perform an operation that removes a lot of data from a database, and then only when you do not expect to use that free space again.
    Because shrinking causes index fragmentation, do not shrink database files regularly. Instead, shrink database files only in response to large quantities of unused space that appear as a result of operations that significantly impact the
    relative amount of used space in a database. If at all possible, avoid shrinking a database.
    However, if you must shrink a database, use the following guidelines:
    •Do not auto-shrink databases or configure a maintenance plan that programmatically shrinks your databases.
    •Shrink a database only when users or administrators remove 50% or more of the content and you do not expect to reuse the unused space.
    •Shrink only content databases. Users and administrators do not delete enough data from the configuration database, Central Administration content database, and various service application
    databases to contain significant free space.
    •Shrinking databases is an extremely resource-intensive operation. Therefore, if you absolutely must shrink a database, carefully consider when you schedule the shrink operation.
    •After you shrink a database, the indexes in that database are fragmented. Use ALTER INDEX… REORGANIZE to address the fragmentation. If you are not configured to allow instant file initialization,
    shrink the database to a target size that accommodates the size required for the near-term growth that you expect. For more information, see
    Database File Initialization.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Datafile size minor than 4 Gb: is this a bug?

    Hi all! I have a tablespace made up by 1 datafile (size = 4 Gb). Oracle 9.2.0.4.0 (on Win2k server) seems incapable of managing this; in fact, I receive ora-04031: unable to allocate 8192 bytes of shared memory but the memory of Oracle is configured correctly. Resizing this tablespace and adding a new datafile so that every datafile is 2 Gb large, I don't receive the error any longer. what do you think about this?
    Bye. Ste.

    Hello everybody;
    The Buffer Cache Advisory feature enables and disables statistics gathering for predicting behavior with different cache sizes. The information provided by these statistics can help you size the Database Buffer Cache optimally for a given workload. The Buffer Cache Advisory information is collected and displayed through the V$DB_CACHE_ADVICE view.
    The Buffer Cache Advisory is enabled via the DB_CACHE_ADVICE initialization parameter. It is a dynamic parameter, and can be altered using ALTER SYSTEM. Three values (OFF, ON, READY) are available.
    DB_CACHE_ADVICE Parameter Values
    OFF: Advisory is turned off and the memory for the advisory is not allocated.
    ON: Advisory is turned on and both cpu and memory overhead is incurred.
    Attempting to set the parameter to the ON state when it is in the OFF state may lead to the following error: ORA-4031 Inability to allocate from the Shared Pool when the parameter is switched to ON. If the parameter is in a READY state it can be set to ON without error because the memory is already allocated.
    READY: Advisory is turned off but the memory for the advisory remains allocated. Allocating the memory before the advisory is actually turned on will avoid the risk of ORA-4031. If the parameter is switched to this state from OFF, it is possible that an ORA-4031 will be raised.
    Make sure too that you dont need to use RMAN program to make backup...baceuse the large pool is used to this too.
    Regards to everybody
    Nando

  • Can I shrink the size of a form text box based on the content?

    We are helping a customer migrate from some MS Word forms to use pdf forms.  We are screenscraping the data from an AS400 green screen system and populating these new pdf forms with data.  however some of the text boxes are in the middle of a sentence and the text box needs to be large enough to fit 50 characters but there are many times when the data we are entering is much less than 50.  The resulting document looks very strange with all of that extra white space in the middle of a sentence due to the size of the text box.
    So can we somehow shrink the size of the text box to fit the number of characters in the box?
    I considered making the box smaller and setting the font size to auto but I think that would look even more strange to have a word with smaller font in the middle of a sentence.
    Thanks,
    Trent

    Sorry, I should have mentioned I am using acrobat professional 9.  I see that I can change the size of the text field when I am designing the form but what I don't see is how to dynamically change the size of the text field based on what data is put inside it.
    Thanks,

  • By mistake, I shrink the size of a particular page, which firefox then remembers. How do I get the size back to normal?

    When moving around on websites, somehow I manage to shrink the size of what is shown on the screen. I have not figured out how to get the size back to 'normal'. However, Firefox remembers this so when I reenter this particular size, it will still be in the smaller format. Very frustrating and as this has happened for at least two of my most watched sites, I am more and more using competing formats, e.g. Explorer.
    I have alsl asked more experienced users of Internet to try to solve this but they are as lost as I am.
    Looking forward to getting your advice.
    Best regards,
    Lars Henriksson

    You can hit CTRL++ to zoom. Or install these add-ons:
    https://addons.mozilla.org/en-US/firefox/addon/theme-font-size-changer/
    https://addons.mozilla.org/en-US/firefox/addon/zoom-page/

  • ASM on SAN datafile size best practice for performance?

    Is their a 'Best Practice' for datafile size for performance?
    In our current production, we have 25GB datafiles for all of our tablespaces in ASM on 10GR1, but was wondering what the difference would be if I used say 50GB datafiles? Is 25GB a kind of mid point so the data can be striped across multiple datafiles for better performance?

    We will be using Redhat Linux AS 4 update u on 64-bit AMD Opterons. The complete database will be on ASM...not the binarys though. All of our datafiles we have currently in our production system are all 25GB files. We will be using RMAN-->Veritas Tape backup and RMAN-->disk backup. I just didn't know if anybody out there was using smallfile tablespaces using 50GB datafiles or not. I can see that one of our tablespaces will prob be close to 4TB.

  • I need to shrink the size of my 5gb fcp x movie so I can upload it to a specific site. If I buy this compressor will it be able to do that?

    The file is currently just over 5gb and the site where the video needs to be uploaded will not take anything over 5gb. Is this the type of program I need to shrink the size of my project or should I use/do something else?

    Hi Russ,
    Thanks again. I feel like I"m so close and hitting stumbling blocks and not finding answers when I google it.
    After I hit submit a sub box pops up with:
    Name: name of my video
    Cluter: Options or none or other
    Priority: High
    It then gives me an option to cancel, but the submit button on this box is greyed out.

  • Maximum datafile size for sqlloader

    Hi,
    I would like to load data from 4GB xls file into oracle database by using sql*loader. Could you please tell me the maximum datafile size that can support sql*loader?
    Thanks
    Venkat
    Edited by: user12052260 on Jul 2, 2011 6:11 PM

    I would like to load data from 4GB xls file into oracle database by using sql*loader. Could you please tell me the maximum datafile size that can support sql*loader?you can post this question in SQL loader forum questions. CLose the thread here.
    Export/Import/SQL Loader & External Tables

  • When converting a document on Pages to PDF, is there a way to shrink the size of the PDF document?

    When converting a document on Pages to PDF, is there a way to shrink the size of the PDF document?

    When exporting you are given 3 options:
    Good, Better, Best
    But I am guessing you are asking something else, just haven't said so.
    Peter

  • My photos shrink in size when emailed from IPHOTO or attached - How can I fix this. My friends say they can't see my pictures... thanks!!

    My photos shrink in size when emailed from IPHOTO or attached - How can I fix this. My friends say they can't see my pictures... thanks!!

    When you email from iPhoto, you have a choice as to the size of the picture - choose medium and your friends will be able to see them.  By the way, do your friends click on the photo attachment  in the mail to open it?

  • Can we decrease the datafile size in 8.1.7.4

    Hello All-
    I have created a sample db with table space with datafile size of 2 GB. I may be needing hundreds of mb only.It is eating up the space on unix box server.
    Is there any way I can decrease the size of the datafile attached to the tablespace in Oracle 8.1.7.4.
    Any help would be appreciated.
    Thanks
    Vidya R.

    Yes you surelly can
    SQL> ALTER DATABASE DATAFILE '/u02/oracle/rbdb1/stuff01.dbf'
    RESIZE 100M;
    Cheers !!
    Jagjit

  • What would be the maximum datafile size that can support sql*loader

    Hi,
    I would like to load datafile from xls file which nearly 5 gb into oracle table by using sql*loader. Could you please tell me how much is max datafile size we can load by using sql*loader?
    Thanks
    VAMSHI

    Hello,
    The Size limit is mainly given by the OS. So you should care about what the OS could support as SQL*Loader files are unlimited on *64 Bit* but limited to *2GB* in *32 Bit* OS:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10839/appg_db_lmts.htm#UNXAR382
    Else, you should be able to load these data into the Table. So you must check that you have enough place inside the Tablespace and/or the Disk (if the Tablespace has to be extended).
    Please find enclosed a link about SQL*Loader and scroll down to Limits / Defaults:
    http://www.ordba.net/Tutorials/OracleUtilities~SQLLoader.htm
    Hope this help.
    Best regards,
    Jean-Valentin

  • How to shrink the size of JRE?

    Hi,
    I wrote a simple Java utlity that performs some business logic for my clients. It is going to run on Windows environments. I created a .exe for this Java application. Obviously It also needs JRE. I made sure that JRE is also shipped along with this application. But the size of JRE is around 70 MB. Is there anyway to shrink the size of JRE? What is best practice for such a thing?
    Thanks in advance,
    Mustafa

    I'm not sure what the licensing implications are of customizing your own derivative of Sun's JRE, presuming that's the one you're using. If the agreement permits, you could remove classes you know that you won't use from the runtime JAR.
    Your best bet, though, sounds like using a Java-to-native compiler. There are a number of applications out there that could produce a Windows executable from your Java code and, since you know it's only going to be run on Windows machines, you lose very little if anything by going through this process.
    Best of luck.

Maybe you are looking for

  • Warning message about Rx power high on Catalyst 4900M

    We get the following warning messages in the log on our 4900M: Dec 12 09:21:37.367 EST: %SFF8472-5-THRESHOLD_VIOLATION: Te3/8: Rx power low warning; Operating value: -12.1 dBm, Threshold value:  -9.9 dBm. Dec 12 09:31:37.537 EST: %SFF8472-5-THRESHOLD

  • Photo Orientation Incorrect When Viewing MobileMe

    I've tried to find a solution to this by searching other posts. What I've found is this is not a new problem. I have two AppleTVs and I have the same problem on both units. But this is the real oddity. The photos not only display correctly orientated

  • How to find the process responsible for deleting files

    Hi, We have a process which stores a file in a particular location say /tmp/mydir/. The files getting stored in this directory are getting deleted. Is there any way to find which process is responsible for deleting the file. Is there any way we can t

  • Finding images that have not been tagged?

    How can I search/find images in LR4 that have been imported though not tagged? Thanks.

  • Weird LV 7.0 File names on Macintosh

    When opening a VI, from the Basics 1 course, a screen appears that it cannot find a VI named "AI Sample Channel (scaled value).vi" The required file is found in the 1EASYIO folder, on the computer's hard drive" but LV shows the file name as "AI Sampl