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]

Similar Messages

  • 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 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

  • Transaction log used 200GB unable to shrink

    Hi All,
    Currently I am facing diskspace(0 KB available) issue in one of my application server..
    When I checked SQL server SMS_UDB (is our DB name) containing 70GB but SMS_UDB_LOG (Transaction log) Containing more than 200GB. When I checked the diskspace report 200GB space used (showing Green). I am unable to shrink the file. I am running 2008 SQL with
    simple recovery model. I taken bak to other server.   It's urgent Kindly help me to reduce the transaction log
    thanks

    Hello,
    Please verify if the initial size for the log on the properties of the database is set to big number of MB and for that reason the database
    shrink does not work.
    Please run the following query and share the results with us:
    SELECT
    name,
    log_reuse_wait_desc
    FROM
    sys.databases
    WHERE
    log_reuse_wait_desc='ACTIVE_TRANSACTION'
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Unable to drop datafile after dropping tablespace

    Hi All,
    Trying to Drop tablespace with Datafile, command used is as below
    drop tablespace tims_db including contents and datafiles;
    this was executed successfully, but still the datafile exists... tried dropping from OS, but unable to delete the file... associated trace alert logs are as below
    Dump file c:\oracle\admin\ocprd\udump\ocprd_ora_4236.trc
    Mon Feb 06 03:40:58 2012
    ORACLE V9.2.0.6.0 - Production vsnsta=0
    vsnsql=12 vsnxtr=3
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Redo thread mounted by this instance: 1
    Oracle process number: 14
    Windows thread id: 4236, image: ORACLE.EXE
    *** 2012-02-06 03:40:58.562
    *** SESSION ID:(52.7127) 2012-02-06 03:40:58.500
    ORA-01259: unable to delete datafile E:\ORACLE\ORADATA\OCPRD\TIMSDB01.DBF
    ORA-27056: skgfrdel: could not delete file
    OSD-04024: Unable to delete file.
    O/S-Error: (OS 32) The process cannot access the file because it is being used by another process.
    OS : Windows 2000
    DB : Oracle 9i
    Please help
    Thanks

    user1687821 wrote:
    As this is a production instance, we need approval to bounce it, If you are sure this file isn't needed - unlock with unlocker and move to some place for a while. Then kill it or kill it immediatly.
    Secondly will the database ask for missing datafile when restarted the database even if it is not listed in dba_data_files...?If your tbs drop was successfull - everything will be fine

  • IOS 7 wallpaper unable to shrink and fit ...

    IOS 7 unable to shrink and fit, this is horrible when i use my old wallpaper...
    Please fix this bug, i can careless about the parallax ****,just want my wall paper back to normal!!!

    Have you tried pinching inwards?
    Regards,
    Steve

  • 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

  • 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

  • Unable to extend datafile which is autoextend on.

    Hi All,
    I am facing interesting problem in
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    SunOS XYZ 5.10 Generic_138888-07 sun4u sparc SUNW,Sun-Fire-880
    Datafile is autoextend on and enough free space is available in mount point on OS, but datafile is unable to extend.....
    Below are the details:
    select file_name,AUTOEXTENSIBLE from dba_data_files where tablespace_name='I_20090414_4';
    FILE_NAME                                                                                                      AUTOEXTENSIBLE
    /mnt/tfmdtwmna01/apps3/oradata/wmsgivn/i_20090414_4.dbf                                   YES
    SQL> !df -h /mnt/tfmdtwmna01/apps3/
    Filesystem             size   used  avail capacity  Mounted on
    ABCDEF.cda.com:/vol/vol3/apps3
                           315G   201G   114G    64%    /mnt/tfmdtwmna01/apps3Did anyone have faced this type of issue????? I think this database is hitting some bugs....
    Some inputs:
    OS was recently upgraded to Solaris 5.10 and Database was also recently upgraded from 9.2.0.7 to 9.2.0.8
    Please help!!!!!
    -Yasser
    Edited by: YasserRACDBA on Apr 15, 2009 6:18 PM

    SQL> sho parameter block
    NAME                                 TYPE        VALUE
    db_block_buffers                     integer     0
    db_block_checking                    string      FALSE
    db_block_checksum                    boolean     TRUE
    db_block_size                        integer     8192
    db_file_multiblock_read_count        integer     16-Yasser

  • UNABLE TO RENAME DATAFILE

    Hi
    I tried to rename a datafile by making the datafile and table space offline,
    I am getting the following error messages
    SQL> alter tablespace usersdata rename datafile '/home/oracle/DB11G/usersdata03.dbf' to '/home/oracle/DB11G/usersdata04.dbf';
    alter tablespace usersdata rename datafile '/home/oracle/DB11G/usersdata03.dbf' to '/home/oracle/DB11G/usersdata04.dbf'
    ERROR at line 1:
    ORA-01525: error in renaming data files
    ORA-01141: error renaming data file 8 - new file
    '/home/oracle/DB11G/usersdata04.dbf' not found
    ORA-01110: data file 8: '/home/oracle/DB11G/usersdata03.dbf'
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3
    Y ITS NOT HAPPENING ???????
    Thnaks in adv..

    ##how to move datafiles.
    1. Shut down the database E.G: shutdown immediate
    2. Move datafiles by OS commands. mv /oracle/product/dbs/test02.dbf /oracle/oradata/ORALOG/test02.dbf
    3. Startup the database in mount state e.g: startup mount
    4. Rename that file e.g: alter database rename file '/oracle/product/dbs/test02.dbf' to '/oracle/oradata/ORALOG/test02.dbf';
    5. Open the database e.g: alter database open
    http://www.oracle-base.com/articles/misc/RenamingOrMovingOracleFiles.php
    Regards
    Asif Kabir

  • Unable to Resize datafile Oracle 9i.

    Hello All,
    I am facing very strange problem in our customer testbed.
    The customer data file grows to till 8GB having 80 Lac records. We deleted approximately 70Lac records but we are not able to re size the data file. When i checked the free space in the file, it shows 0.
    Can you please let me know how to re size the data file.
    The Database server is windows server 2003 32 bit.
    Thanks
    With Regards
    Hemant.

    I dont think moving the tables to another tablespace is a solution to this issue.. when you move the tables to a different tablespace, they are going to take the same amount of space, so if you shrink the original tablespace, you may very possibly not be able to restore them in the original tablespace. The point is you need the space freed up in the table to free it up in the datafile or the 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

  • Disk Utility - Unable to Shrink Disk Error

    hey guys,
    I have been trying to shrink my system partition but i keep getting an error.
    I had Vista installed on a boot camp partition, but i needed to reinstall it and i decided to start from scratch. I erased the vista partition and tried to recreate it. I ran boot camp assistant but that failed at creating a new partition.
    I ran disk utility to first try and shrink the system drive, then increase the size to full before i rerun the boot camp partition. however, i cannot shrink.
    this is the error i get.
    http://dl.getdropbox.com/u/734117/Screen%20shot%202009-10-25%20at%208.48.54%20AM .png
    I had only about 35 gigs free and i tried to create a 20 gig partition. after that error, i erased some data and now have just under 100 gigs free. but the drive still cannot shrink
    I was hoping to find a way to shrink the drive, or defragment without having to erase the entire disk and reinstall. i do not have the backup capabilities to move all my data at this point.
    Thanks for your help

    Hahmad wrote:
    How do i create a clone?
    first, you need an external drive. then use CCCloner http://www.bombich.com/index.html
    or Superduper http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html
    to clone the OS X partition to the external. make sure that the external is formatted with GUID partition scheme before cloning. if needed reformat it first with disk utility.

  • Unable to shrink the connections

    HI,
    I am using weblogic 6.1 connection pooling. I am facing problem in shrinking
    the connections
    I set the connection parameters as
    Initial capacity = 2,
    Increment = 1
    Max capacity = 10
    Allow shrinking = true
    When I open 4 sessions simultaneously it shows the
    connections = 4
    total connections = 4
    Waiters = 0
    Connections high = 3
    After several time accessing the database it shows
         Connections = 0
         Total connections = 13
         Connections high = 3
         Waiters = 0
    My problem is even after shirking time also it shows the active connections in
    the database side(I tested using v$session).are there any extra setting is needed
    for the shrink to take place?(other than setting it to true in console). I even
    tested using the code ( getting the pool and executing the shrink() method).
    My second doubt was why it is showing total connections as greater than maximum
    capacity. I am not clear on the no shown for total connections.
    I would be thankful if some looks into it.
    Thanks

    Make sure the application is returning all the connection to the pool (close
    all connections in the finally blocks). If connections are not closed in
    your application they cannot be removed from the pool.
    hth
    sree
    "nambudri" <[email protected]> wrote in message
    news:3c33e8f1$[email protected]..
    HI,
    I am using weblogic 6.1 connection pooling. I am facing problem in
    shrinking
    the connections
    I set the connection parameters as
    Initial capacity = 2,
    Increment = 1
    Max capacity = 10
    Allow shrinking = true
    When I open 4 sessions simultaneously it shows the
    connections = 4
    total connections = 4
    Waiters = 0
    Connections high = 3
    After several time accessing the database it shows
    Connections = 0
    Total connections = 13
    Connections high = 3
    Waiters = 0
    My problem is even after shirking time also it shows the active connections
    in
    the database side(I tested using v$session).are there any extra setting is
    needed
    for the shrink to take place?(other than setting it to true in console). I
    even
    tested using the code ( getting the pool and executing the shrink() method).
    My second doubt was why it is showing total connections as greater than
    maximum
    capacity. I am not clear on the no shown for total connections.
    I would be thankful if some looks into it.
    Thanks

  • Unable to shrink tlog

    Hello,
    Usually,the tlog backup goes to tape but it's giving some error.I took the backup on disk and then doing tlog shrink but it's not happening.
    Please advise.
    Best regards,
    Vishal

    Hello,
    Usually,the tlog backup goes to tape but it's giving some error.I took the backup on disk and then doing tlog shrink but it's not happening.
    Please advise.
    Best regards,
    Vishal
    You might need to take log backup twice to actually be able to shrink the log file.please run DBCC LOGINFO(DB_NAME) and see if status column last value is 0 or not unless it is zero you wont be able to shrink.
    You can also use below query to see what is holding your log from truncating'.If it is  log backup you need to take log backup.
    select name,log_reuse_wait_desc from sys.databases where name='db_name
    Problem with tape log  backup is there are 2 options to take log backup one just log backup (plain) and other take log backup and truncate logs hope you have selected second option.Else please take log backup using TSQL
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Maybe you are looking for

  • Best app to clean up my laptop?

    My laptop is a few years old and getting slow, I downloaded the demo of MacKeeper and it said I have a lot of issues, what I want to know is which is the version that will fix those issues? Will the basic version do it? I don't want to pay for the 60

  • External Hard Drives Suddenly being removed:

    I have two different external hard drives that I use for storing video (1 Seagate and 1 Western Digital). Over the last few days I have had them powered up one at a time. After about 10 minutes, I receive an alert that says that a "device wasn't prop

  • [SOLVED] Update GNOME 3.16 (testing) to 3.16.1 (extra) and can't login

    I no longer have any testing package, but when gdm starts I get a blinking mouse pointer (it blinks 5 times) and then I get the gdm screen but without any user list. If I open the menus (date menu, the shutdown menu, ...) I can see they leave a "trac

  • Audio sometimes missing on imported QTs

    hi all. sometimes when i import a QT into AE the audio seems to go missing. if i play the QT on the desktop it's fine but inside the little switch controlling whether you hear the audio or not is greyed out or solid. it seems to be an intermittant er

  • E4200 - Could not get it to work

    I spent several hours trying to automatically and manually set this up with bad results. What's great about it: Nothing What's not so great: Hard to set up; didn't work