Shrinking Datafiles.

A user has loaded up a table which has caused the RBS datafile to grow to over 3GB. Even though I have shrinked each of the roll back segments back to 4MB each I am still unable to resize the data file down to a more managable value. When using the "alter database datafile ... resize" command I get a "ORA-03297 file contains used data beyond requested resize value".
I get this even if I try to reduce the size to 2GB. Is it possible to rebuild the datafile and compact the extents to allow me to reduce the size of the datafile.
I am working with Oracle 8i (8.1.7).
Any help appreciated.
Richard

Richard:
About the only option is to create a new tablespace, then create new rollback segments in that tablespace and put them on-line. Then, take the rollback segments in the old tablespace off-line. You may have to wait a bit for active transactions before you can off-line the old rollback segments.
Once all of the old rollback segments are off-lined, you can drop the old tablespace.
Having said that, since your existing rollback tablespace did grow to 3Gb, are you sure that you do not need 3Gb? If you areworried about it consuming even more space, you could set auto extend off for the datafiles.
Disk is cheap.
John

Similar Messages

  • 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

  • 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

  • Try to shrink datafiles after deleting huge amount of records

    Dear Sir;
    I have deleted more than 50 million records along with table’s partitions for the previous year.
    now I'm trying to shrink datafile with more than 10GB free space but still unable to delete due to
    ORA-03297: file contains used data beyond requested RESIZE value.
    How can we shrink these datafile or otherwise what is the best way to delete huge amount of records and get additional space in HD
    Thanks and best regards
    Ali Labadi

    Hi,
    You could see this article of Jonathan LEWIS:
    http://jonathanlewis.wordpress.com/2010/02/06/shrink-tablespace

  • Shrink Datafiles

    Hi Gurus!
    I got a DB around 12Tb used and the Company is planing to reduce 30% of this space, deleting some periods.
    After to reduce the space used in database, I´ll need to release as much as I can in all tablespaces, because I´ll need to move the datafiles to another storage and release the current one.
    I got a doubt if can I shrink the datafiles and after that, to try to resize all of them.
    Unfotunatelly, I don´t have enough space to create other tablespaces toward to do a reorg.
    Is it a good idea to try to shrink the concerned datafiles and after, to resize it?
    Thanks in advance.
    Regards,
    Leonardo

    Hi Gurus!
    I got a DB around 12Tb used and the Company is planing to reduce 30% of this space, deleting some periods.
    After to reduce the space used in database, I´ll need to release as much as I can in all tablespaces, because I´ll need to move the datafiles to another storage and release the current one.
    I got a doubt if can I shrink the datafiles and after that, to try to resize all of them.
    Unfotunatelly, I don´t have enough space to create other tablespaces toward to do a reorg.
    Is it a good idea to try to shrink the concerned datafiles and after, to resize it?
    Thanks in advance.
    Regards,
    Leonardo

  • Unable to shrink datafile

    Hello Gurus,
    Env: SQL Server 2008 R2 installed on Windows Server 2008.
    DAS based storage.
    Issue: DBCC showfilestats shows that all of the exents are used. This means there is no
    Unable to shrink the data file.
    Description: The data file is growing by a GB every day approx.
    I see the existing space with in the data file is not being used and it is allocating fresh extents every time.
    When I do the DBCC showfilestats it says all of the extents are in use and there is almost nothing free.
    The size of the data file is 200 GB.
    When I run the top 50 tables by size, I see the sum of all of these tables is hardly 10GB.
    I know there is not much data with in the tables.
    When I am trying to shrink the data file, it gives the error message "A severe error occurred on the current command."
    I tried to follow the following till date, nothing worked till date.
    DBCC checkDB and then tried to shrink.
    Took the database in the single_user mode and then tried to shrink.
    Ran a checkpoing and then the log backup job and then tried to shrink.
    So there are two questions.
    1. How shall we shrink the data file?
    2. Why is it not using the existing space with in the file?
    Please letme know if I need to send more details.

    1. How shall we shrink the data file?
    Why would shrink it, when The data file is growing by a GB every day approx. Database files should rather not autogrow. They should be extended well in advance in a maintenance window. I would suggest that you increase the database
    with 50 GB.
    Shrinking a database is a very exceptional operation which you only do when you know that the data size has been reduced on a permanent basis.
    2. Why is it not using the existing space with in the file?
    It is not clear how you have deemed that there is space in the file; au contraire, all evidence points at that is no space available.
    It is possible, though, that your data pages are poorly utiliized. Heaps are particularly prone to this, and you can be left with pages with no or little rows on them.
    Do you rebuild your indexes regularly? Do you have any heaps? What does this query return:
    SELECT COUNT(*) FROM sys.indexes WHERE index_id = 0
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to shrink datafiles after droping table

    Hello Gurus,
    I have just dropped a big table but see that the file hasn't change..
    Could you help me to shrink a file too?
    Thanks!
    Agat

    <br>Agat,</br>
    <br>Yesterday it was the same question in this forum : Shrink tablespace ? how can i do that?</br>
    <br>Nicolas.</br>

  • Options for resize datafile lower than high watermark besid alter table mov

    hello all,
    I have an issue where i am getting ORA-03297 error when trying to resize the datafile. Its becuase of high watermarks. I know i have couple of options...either resize it till the high watermark or Drop or move segments containing extents in this region prior to
    resizing the file....but the situation is this....this a test env...and we have couple of chained rows and doing that(alter table move) will get rid of our chained rows and we do not want that....as we are testing the removal of chained row from our prod systems....as i mentioned we cant do alter table move
    what other options do we have in order to shrink datafile below highwater mark besides moving or droping the segment into a different tablespace as we want to preserve the chianed rows for our testing and making the DB smaller in size (space issue on the server ) ??? any ideas or any thoughts ??
    we are on 10.2.0.3 on AIX system
    i have already went thru these metalink doc .... on that error
    Note 1029252.6 - How to Resize a Datafile
    Note 130866.1 - How to Resolve ORA-03297 When Resizing a Datafile by Finding the Table Highwatermark
    Note 237654.1 - Resizing a Datafile Returns Error ORA-03297

    i am sorry not able to get your question ??
    I want to shrink the space of the Datafile without removing the chaned rows for testing the removal of chianed row for prod. The reason why is becoz of rman backup space issue. If we shrink the datafile our DB will be down to 150GB....and if we cant its about 450GB...which is big difference...and the reason for backup for this dev env is because once we have tested teh removal of chained rows...we will restore it again and re-test it and its a very mission critial system...we need to test this min of 3 times to get teh change approved...thats why...if we have a backup now...we can remove chain rows and then restore it back to this point and test it again...if you know wat i mean

  • Table move after data deletion in oracle 11g

    Hi,
    Our previous system was in oracle 9i, And we used to archive our data in every 1 year which caused a huged number of DML operation our database. After that,we used to move our table and rebuild indexes to releases spaces. After Upgradation ,our presence system is running on oracle version 11.2.0.2. Now my question do we need to move table in 11g to release space?? Or it automatically done in 11.2.0.2???
    Thanks and Regards,

    Our previous system was in oracle 9i, And we used to archive our data in every 1 year which caused a huged number of DML operation our database. After that,we used to move our table and rebuild indexes to releases spaces. After Upgradation ,our presence system is running on oracle version 11.2.0.2. Now my question do we need to move table in 11g to release space?? Or it automatically done in 11.2.0.2???If you move that space will be released from those extents but you wont gain any space at OS level until unless you shrink datafile. Move command will do the job.
    did you see what is the free space in tablespace after moving objects?

  • TableSpace Objects and Size

    Hello Oracle Community,
    DB: 11.1.0.7.0
    How can I see what database objects (tables, indexes, etc.) are stored in a given tablespace and what is the best way to shrink the size of a tablespace/datafiles ?
    IKrischer

    You can see the mapping of objects to tablespaces as well as the amount of space an object takes up by using the DBA_SEGMENTS view. As far as shrinking datafiles you may want to check out this AskTom thread: Reclaim space

  • Reclaim space from DBFs

    Hi All,
    I have one query regarding tablespace reclaim space. I have users tablespace which is having 5 dbfs. Some of the DBFs of USERS tablespace having autoextend on with max size 32G and some of the DBFs not having autoextend on and maxsize 4G.
    Now when I checked the USERS TBS through EM , I come to know only few MBs out of 20G are in used in 3 DBFs of USERS tablespace and rest of 2 dbfs are in good in use. Now I want to reclaim the space from 3 dbfs say users03,users04 and users05. users01 and users02 are properly in used. I want to reclaim the space from 03,04 and 05.
    can I have any idea how to reclaim space from dbfs? I try with alter database datafile ...resize but giving error "ORA-03297: file contains used data beyond requested RESIZE value".
    please suggest me,
    Thanks...

    Yes, I think you are understanding how it works. For a visual example, if this is your data file:
    XXXX--XX-XXXX-XXXX-XXXX-XXXXXXX-----------------
    and you delete some data
    XX----X--------X------------------X-----------------
    The datafile can be resized only down to
    XX----X--------X------------------X
    Which tools are available to do this efficiently vary by database version, for example in my 9.2.0.6 database I can use exp/imp, CREATE TABLE AS SELECT, rebuild indexes (mostly) online, exp/imp, move LOBs around with ALTER TABLE ... MOVE LOB, or other strategies - some of these are more work than others, and all will take some amount of time. In 8i There are fewer options; beginning with 10g data pump and DBMS_REDEFINITION are available; in 11g the index rebuilds don't lock the data, so the time may be less of a concern.
    Before you even spend the time to shrink these data files, consider the space needs for USERS. If the extended size was a one-time thing, then shrinking datafiles may be justified. If USERS may grow that large again then a data file shrink is a lot of work for little gain.

  • How to free up space in Tablespace?

    My SQL is quite decent but not perfect.
    I'm using the following sql query to find out the tablespace's free space:
    select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
    from (select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_space
    from dba_free_space
    group by tablespace_name) a,
    (select tablespace_name, sum(bytes)/1024/1024 as tbs_size
    from dba_data_files
    group by tablespace_name) b
    where a.tablespace_name(+)=b.tablespace_name;
    I can see that one tablespace (custom made) is using up a lot of space so i want to free up some space. How can i do that?
    I tried the following but still when running that query it still outputs the same:
    - delete rows (tried using both delete & truncate commands) from schemas (tables) that belong to that tablespace
    - drop unused schemas (tables) that belong to that tablespace
    even tried disconnecting my session and reconnecting again but running that query still returns teh same results :s
    Help much appreciated!
    regards,
    cheers

    911802 wrote:
    My SQL is quite decent but not perfect.
    I'm using the following sql query to find out the tablespace's free space:
    select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
    from (select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_space
    from dba_free_space
    group by tablespace_name) a,
    (select tablespace_name, sum(bytes)/1024/1024 as tbs_size
    from dba_data_files
    group by tablespace_name) b
    where a.tablespace_name(+)=b.tablespace_name;
    I can see that one tablespace (custom made) is using up a lot of space so i want to free up some space. How can i do that?
    I tried the following but still when running that query it still outputs the same:
    - delete rows (tried using both delete & truncate commands) from schemas (tables) that belong to that tablespace
    - drop unused schemas (tables) that belong to that tablespace
    even tried disconnecting my session and reconnecting again but running that query still returns teh same results :s
    Help much appreciated!
    regards,
    cheersOracle NEVER shrinks datafiles automagically.
    You must do so manually.
    http://www.lmgtfy.com/?q=oracle+shrink+datafile

  • Oracle Express 10g Limitations

    The FAQ specify it supports up to 4GB of User Data in addition to Oracle system data.
    How do I know that I have reached the limit of 4GB of user data and what will happen to my application once I have reached this limit?

    You will start to receive an Oracle error message; ORA-12952: The request exceeds the maximum allowed database size of 4 GB
    You may sum bytes columns of dba_data_files and dba_temp_files views and if possible you may shrink datafiles to gain space. A similar sql script can help to identify shrinkable space you have -
    SELECT file_name,
           round(f.bytes / 1024 / 1024) "Total Size M",
           round(f.bytes / 1024 / 1024) - round(s.bytes / 1024 / 1024) "Can be shrunk by M ",
           'alter database datafile ''' || file_name || ''' resize ' ||
           to_char(round(f.bytes / 1024 / 1024) - round(s.bytes / 1024 / 1024)) || ' M ;'
      FROM dba_data_files f, dba_free_space s
    WHERE f.file_id = s.file_id
       AND s.block_id IN
           (SELECT MAX(block_id) FROM dba_free_space WHERE file_id = s.file_id)
    ORDER BY 3 DESCOracle XE has a dedicated forum as referenced below, these references may also help -
    · Installation guide - http://download.oracle.com/docs/cd/B25329_01/doc/install.102/b25144/toc.htm
    · OTN forum needs extra registration(free) - http://www.oracle.com/technology/xe/registration
    · OTN forum support - Oracle Database Express Edition (XE)
    · All documentation - http://www.oracle.com/pls/xe102/homepage?remark=tahiti
    · OTN portal - http://otn.oracle.com/xe
    Also here you may find a summary of limitations over editions - http://www.oracle.com/database/product_editions.html

  • Data-guard conceptual help needed

    Hello Experts,
    We have 2-node RAC Physical standby DG. I got the following doubts in my mind just to clear my concept:-
    1. Can we perform Hang analyze on the DG site, when it is on managed recovery and of-course in read-only mode? if not then Q2?
    2. If both of my DG nodes (in a 2-node RAC DG) are in a hung state while the managed recovery was active, can I do sqlplus sql> set _prelim on and enable oradebug hanganalyze or do I have any other option apart from restarting the DB
    3. IF the Primary RAC (2-node) hangs then if we take systemstate dump / Hanganalyze from the DG site
    I guess, we will not get meaningful results as Hanganalyze will use Kernel system calls of the Server on the DG site and systemstatsdump will dump the SGA of the secondary site instance's SGA
    4. I am using a non-RAC primary and Secondary site and non-ASM disk
    I have my Primary mount -points as /Oradata/Prim1 = 1 TB and Physical standby DG - real time apply mount-point as /Oradata/Seco1 =.8 TB & /Oradata/Seco2 = .2TB and my Primary DB is now on size expansion from .79 TB to .95 TB overnight. I am not intending not to take any down-time nor am I able to extend the disks on the Primary for any reason. what can be done wisely to keep the DR site in close sync?
    Regards,
    Syvalli
    Edited by: user4566776 on Dec 12, 2012 6:04 AM

    We have 2-node RAC Physical standby DG. I got the following doubts in my mind just to clear my concept:-
    1. Can we perform Hang analyze on the DG site, when it is on managed recovery and of-course in read-only mode? if not then Q2?
    2. If both of my DG nodes (in a 2-node RAC DG) are in a hung state while the managed recovery was active, can I do sqlplus sql> set _prelim on and enable oradebug hanganalyze or do I have any other option apart from restarting the DBYes you can perform hang analyze and even you can generate active session history report if DR is on read-only mode.
    SQL> select database_role from v$database;
    DATABASE_ROLE
    PHYSICAL STANDBY
    SQL>
    SQL> oradebug setmypid;
    Statement processed.
    SQL> oradebug unlimit;
    Statement processed.
    SQL>
    SQL> oradebug hanganalyze 3;
    Hang Analysis in /u02/app/oracle/diag/rdbms/CKPT_un/CKPT/trace/CKPT_ora_5113.trc
    SQL>
    SQL> oradebug dump systemstate 266;
    Statement processed.
    SQL>
    [oracle@oracle-stby ~]$ tail -10 /u02/app/oracle/diag/rdbms/CKPT_un/CKPT/trace/CKPT_ora_5113.trc
      Holder:
      SO: 0x8ca2c8b8, type: 83, owner: 0x6000c478, flag: INIT/-/-/0x00 if: 0x3 c: 0x3
       proc=0x90488f50, name=circuit holder, file=kmc.h LINE:2615, pg=0
      (circuit holder) disp = 0x8ca2c830 (0, 1), proc = (0x90488f50, 1)
    END DISPATCHER DUMPS
    END OF SYSTEM STATE
    *** 2012-12-12 20:03:44.100
    Oradebug command 'dump systemstate 266' console output: <none>
    [oracle@oracle-stby ~]$
    3. IF the Primary RAC (2-node) hangs then if we take systemstate dump / Hanganalyze from the DG site
    I guess, we will not get meaningful results as Hanganalyze will use Kernel system calls of the Server on the DG site and systemstatsdump will dump the SGA of the secondary site instance's SGAYes, the hang analysis we should perform from the instance where you have problem. you can use OS level trace if database not accessible by using How to interpret OS system traces [ID 1429678.1]
    4. I am using a non-RAC primary and Secondary site and non-ASM disk
    I have my Primary mount -points as /Oradata/Prim1 = 1 TB and Physical standby DG - real time apply mount-point as /Oradata/Seco1 =.8 TB & /Oradata/Seco2 = .2TB and my Primary DB is now on size expansion from .79 TB to .95 TB overnight. I am not intending not to take any down-time nor am I able to extend the disks on the Primary for any reason. what can be done wisely to keep the DR site in close sync?Can you tell me one thing? After size expanded in primary from .79 TB to .95 TB does your standby is out of SYNC?
    If you do not have space, then you should add some space to the disk to avoid any interruption to production. Or check whether you can adjust HWM on primary database using below method. http://www.oracle-ckpt.com/how-to-shrink-datafiles-adjusting-hwm/
    Hope this helps

  • Decrease tablespace size  that is now empty?

    Howdecrease size of tablespace who had data and now is empty?(10g)

    >
    My tablespace has 27G size but i want to decreae the size to 14G...
    And my tablespce had Data and i could not to drop tablespace!!!
    >
    Yes, you don't have to drop the datafile or tablespace. Just try to shrink it. But remember, you can shrink it only below the high water mark. You may contain only 14 GB in a 27GB datafile but it doesn't mean that your high water mark is just above 14 GB
    To shrink, try this
    Alter database datafile 'datafile_with_full_path' resize 14G;
    If it doesn't work, it's possible that the datafile's HWM is well above it. You may move the objects to a different tablespace and drop the tablespace in that case. Optionally, you can rename the new tablespace to the old tablespace if you want.
    Tell us your Oracle version as well.
    Edit:
    >
    Because My database is in production environment Dose shrinking datafile affect the performance or any effect on database working?
    >
    Shrinking shouldn't affect the performance but it has to do some recursive calls to the database objects. However if you think your tablespace is going to grow anyway soon, why worry about shrinking the datafiles?
    Edited by: VenkatB on Sep 12, 2011 11:19 AM

Maybe you are looking for

  • Resolution to non-playing DVD problem?

    It's been a while since I last dropped in here. Fortunately, I haven't had any problems! I was wondering if anyone ever figured out why so many people were having problems with DVD's that would play in their computers but not on DVD players. I may ha

  • Developing an online web application

    Hi, I'm currently doing my final year project at uni as part of a computer science degree and am designing an interactive breast cancer diagnosis system. At the moment I'm just programming the basic structure including, registration, login,feedback a

  • Statement Generation Program- Incompatability

    Hi, We are trying to find out if the 'Statement Generation Program' can be run simultaneously for more than a customer within a operating unit. Are we expecting to see any issues in terms of the performance or the output if we have the program run si

  • How to pass APEX_UTIL.COUNT_CLICK parameters in the url

    Hello, I have to count clicks on the List items: There is a Click Counting option in the definition of each List item, and you can add Click Count Category there. However, I also need to add Click Id parameter - p_id. This parameter (p_id) suppose to

  • Application message help could not be called Message in SABAPDOCU888

    Hi,                                                                       After the application of the Support Package 21 in the DEV, help is not functioning correctly, for example, in top of word WRITE (in a publisher ABAP), I pressure F1, opens hel