Flawed script for finding free tablespace space

Currently i am using the below mentioned script to see the freespace in tablespace. But the Freespace shown in this report is mistakenly shown smaller than the actual freespace in the datafiles.
For example i ran the below mentioned script and found that the tablespace CUSTDATA has only 4634 MB free. So i added another datafile with 2GB space using the following syntax.
ALTER TABLESPACE CUSTDATA
ADD DATAFILE '/u04/oradata/ora145/ora145_CUSTDATA20.dbf' SIZE 500M AUTOEXTEND ON NEXT 20M MAXSIZE 2000M;
After the addition of this datafile, the freespace should be 6634 MB. But my script's resut is showing only 5134.75 MB.
Why is this happening?
My tablespace free space report script
select ddf.tablespace_name,total ttlSize,
(total-nvl(freespace,0))/1024 used, freespace
from (select tablespace_name,sum(bytes/1024/1024)
total from dba_data_files group by tablespace_name) ddf,
(select tablespace_name,sum(bytes/1024/1024)
freespace from dba_free_space group by tablespace_name) dfs where ddf.tablespace_name=dfs.tablespace_name(+); Message was edited by:
for_good_reason

The MAXSIZE (2000M) is the actual size of the
datafile and not SIZE 500M . Right?No, at least when you create the datafile. Actual size is identified by BYTES column, which you use in your query. Example :
SYS@db102 > select file_name,bytes, maxbytes
  2  from dba_data_files
  3  where tablespace_name = 'USERS';
FILE_NAME                                                     BYTES         MAXBYTES
/home/oracle/base/oradata/db102/users01.dbf               104857600      34359721984
SYS@db102 > select tablespace_name,sum(bytes) from dba_free_space
  2  where tablespace_name = 'USERS'
  3  group by tablespace_name;
TABLESPACE_NAME                      SUM(BYTES)
USERS                                  61341696
SYS@db102 > alter tablespace users add datafile
  2  '/home/oracle/base/oradata/db102/users02.dbf'
  3  size 100M autoextend on next 10M maxsize 500M;
Tablespace altered.
SYS@db102 > select file_name,bytes, maxbytes
  2  from dba_data_files
  3  where tablespace_name = 'USERS';
FILE_NAME                                                     BYTES         MAXBYTES
/home/oracle/base/oradata/db102/users01.dbf               104857600      34359721984
/home/oracle/base/oradata/db102/users02.dbf               104857600        524288000
SYS@db102 > select tablespace_name,sum(bytes) from dba_free_space
  2  where tablespace_name = 'USERS'
  3  group by tablespace_name;
TABLESPACE_NAME                      SUM(BYTES)
USERS                                 166133760
SYS@db102 >

Similar Messages

  • How to make a script for find text object?

    Hi everyone
    I want to make a script for find and select text object and then find next, find next, and so on, but without any open dialog
    Is that possible make a script for this?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "(\[\x{2022}\])|(\x{25CF})";
    app.findGrep();
    thanks
    Regard

    You already have that. A script does not 'find, select, find next' - it finds all texts as soon as you execute the 'app.findGrep' command.

  • HELP !!! - sql script to find free space in Oracle7,8,9 DB

    Hi All
    I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
    Please help. !!!
    Script
    set feedback off;
    set serveroutput on;
    set termout off;
    set verify off;
    spool /u01/app/oracle/admin/common/bck/log/ts.log
    declare
    v_tablespace_name varchar2(50);
    v_total_space number(12) := 0;
    v_free_space number(12);
    v_space number(12);
    v_space_used number(12);
    v_pct_free number(6,3);
    v_pct_threshold number(3) := 2;
    v_table_exist number(2) := 0;
    v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
    TYPE t_tableref IS REF CURSOR;
    t_tablecur t_tableref;
    begin
    for tablespace_rec in (select tablespace_name from dba_tablespaces)
    loop     
    -- Get the total space for the current tablespace
    -- if this FILEXT$ view exists then some of the datafiles have autoextend on;
              select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
              dbms_output.put_line('table count: ' || v_table_exist);               
              if v_table_exist = 0 then
                        OPEN t_tablecur for v_sql;
                        fetch t_tablecur into v_total_space;                         
                        CLOSE t_tablecur;     
              --     select sum(maxbytes) into v_total_space from dba_data_files
              --     where TABLESPACE_NAME = tablespace_rec.tablespace_name;               
              --      v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
              end if;
              select sum(bytes) into v_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;          
         if (v_total_space = 0 or v_total_space < v_space) then
              select sum(bytes) into v_total_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
         else
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              v_space_used := v_space - v_free_space;
              v_free_space := v_total_space - v_space_used;          
         end if;
    -- calculate the percent free for the current tablespace
    v_pct_free := (v_free_space / v_total_space) * 100;
         if (v_pct_free < v_pct_threshold) then
         dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free      
         ||'%');
         end if;
    end loop;
    end;
    spool off;

    Hi All
    I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
    Please help. !!!
    Script
    set feedback off;
    set serveroutput on;
    set termout off;
    set verify off;
    spool /u01/app/oracle/admin/common/bck/log/ts.log
    declare
    v_tablespace_name varchar2(50);
    v_total_space number(12) := 0;
    v_free_space number(12);
    v_space number(12);
    v_space_used number(12);
    v_pct_free number(6,3);
    v_pct_threshold number(3) := 2;
    v_table_exist number(2) := 0;
    v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
    TYPE t_tableref IS REF CURSOR;
    t_tablecur t_tableref;
    begin
    for tablespace_rec in (select tablespace_name from dba_tablespaces)
    loop     
    -- Get the total space for the current tablespace
    -- if this FILEXT$ view exists then some of the datafiles have autoextend on;
              select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
              dbms_output.put_line('table count: ' || v_table_exist);               
              if v_table_exist = 0 then
                        OPEN t_tablecur for v_sql;
                        fetch t_tablecur into v_total_space;                         
                        CLOSE t_tablecur;     
              --     select sum(maxbytes) into v_total_space from dba_data_files
              --     where TABLESPACE_NAME = tablespace_rec.tablespace_name;               
              --      v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
              end if;
              select sum(bytes) into v_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;          
         if (v_total_space = 0 or v_total_space < v_space) then
              select sum(bytes) into v_total_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
         else
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              v_space_used := v_space - v_free_space;
              v_free_space := v_total_space - v_space_used;          
         end if;
    -- calculate the percent free for the current tablespace
    v_pct_free := (v_free_space / v_total_space) * 100;
         if (v_pct_free < v_pct_threshold) then
         dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free      
         ||'%');
         end if;
    end loop;
    end;
    spool off;

  • Window 10 On ICONIA W510 using WIMBoot for more free disk space.

    What is this ...WIMBoot is a feature that we can boot from .wim file instead of extract content to harddrive.WIMBoot made for computer or tablet that have small size of storage (eg. 32GB OR 16GB) for increase for free storage space. And make device have ability to recover, resetting, reinstall windows without windows installation disk.After windows 8.1 Updated we can use WIMBoot feature and now I use this feature for windows 10 to boot our Iconia W510 tablet.(More about WIMBoot : WIMBoot Overview) (SEE MY PREVIOUS POST ABOUT WIMBoot FOR ICONIA W510 WITH Windows 8.1 Updated : HERE!!)   Screen Shot ... This picture is system detail as you see windows is activated!  This picture show free space after clean install. Around 24GB free space.In C: drive it have more partition space than windows 8.1 update As you see Windows C: used around 2.79GB for pagefile and hibernate files.  With my installation. My windows have activated...
    I do not know with your installation it will activate or not, I can't confirm this, you must try for your own risk. What will you get with this. More freespace for your drive. (Around 24GB)Ability to use recovery function of windows (Recover, Resetting, Reinstall) without installation media.Before you go :: Please READ!!This solution is for ICONIA W510. But you can apply to another windows tablet that use Atom z2670 (Or other I can't comfirm must try for your own risk).I add W510 Drivers to this image you can use your docking. If you don't have docking you can use USB Hub for more usb port to use with USB Flashdrive, USB Keyboard, USB Mouse.About windows Activated... I'm not guarantee it will activated or not. MUST TRY ON YOUR OWN RISK. It seem product key in UEFI/BIOS not work.This solution will wipe all your storage partition. Please backup your data to your safe place.This solution cannot downgrade to your old windows.This windows 10 is from media creator tool. It is windows 10 Core Single Language with english version only.(I will add solution to add language to installation later [if i have more time].)If this solution helpful you can buy me some beer!!!  Download Tools AND Files.WindowsPE & WIMBoot Image for ICONIA W510.Need 5 files (file .md5 use for check file hash)winpe.isosource.7z.001source.7z.002source.7z.003source.7z.004Download HERE.One Drive : http://1drv.ms/1N90FWTGoogle Drive : https://goo.gl/5bCnlrRufus for create USB Bootable : https://rufus.akeo.ie/7zip for extract file : http://www.7-zip.org/download.htmlRapicCRC for check file hash (IF NEED) : http://rapidcrc.sourceforge.net/YOU NEED USB Flash Drive 4GB or larger.    Solution.... 1. preparing Bootable Media.Create bootable flash drive using Rufus. See PICTURE.Prepare WIMBoot fileExtract file "source.7z.00x" using 7zip if it ask for password enter "aphorist".You will see 3 file.partition.txtinstall.cmdinstall_wimboot.wimCopy ALL files to Bootable Flash Drive in folder "SOURCE".2. Preparing Tablet for boot from USB.Shutdown your tablet.When your tablet shutdown completely.
    ---> Hold down volume down button.
    ---> Then hold down power button.
    ---> When acer screen appear release all botton.UEFI appear.
    Go to Security and set supervisor password.
    (If not you will not able to disable safeboot and can't boot to usb thumdrive.)
    (PLEASE REMEMBER YOUR PASSWORD CAFULLY!!!!)
    Go to Boot and set Secureboot to Disable. Then move USB HDD: to upper.
    Go to Exit and select Exit saving changes. Your tablet will restart and boot as normally. Please shutdown again.3. Boot to Windows PE from USB Flash Drive and install Windows 10.Connect your bootable flash drive (From step 1).For sure you must remove micro-sd card now.Then power on your tablet. AND Wait.......In boot process you don't need to do anything it will boot to flashdrive when it completed you will see command prompt. (Some time it boot so long depend on speed of your USB Flash drive.)Windows PE will look like this.
    Thank picture from svrops.comIn the command box. Type.
    > d:
    > cd source
    > installThe script will wipe your drive and recreate it in WIMBoot partition layout then apply image for you.
    Now... need to relax go to rest or just watching the screen. When completed your tablet will reboot automatically.If windows ask for product key just click skip.Completed....FYIK.This solution not confirm that you will get windows be activated or not.This windows 10 is "Single Language" edition and in English (United state) language.
    If I have more time I will add solution to add another language later.AGAIN if you like this please buy me some beer....  

    I suspect that the problem with the Intel GMA has been fixed, at least my W3 which is effectively the same 2760 archetecture as the W510 installed as update, and a W510 should install normally. For the w3 when Win10 complained about "not enough room" I just pointed it at the 64GB microSD and it put the recovery files there. Why did you need to remove yours ? Giving it a few days then I'll probably upgrade the 510 as well. BTW the W3 is handling dual big monitors & the Targus dock on W10 with no problem. Plays video nicely.

  • Script for finding characters in a folder or file name

    I need some help on writing a script that will search thru users folders and files and replace characters in the names with a different character. Our users folders go back to when the users used OS 9 and they used / \ * ? in the file and folder names, I want to write a script that will replace these characters with an _ . Obviously I will need to be logged in as the root user.
    The server is OS 10.3.9
    Thanks,
    Jeff
      Mac OS X (10.3.9)  

    Hi Roger,
       There's a flaw in your regular expression and that is the absence of alternation. You want to replace any one of these characters with an underscore. That can be accomplished by putting the characters in a character class. Since the class matches a single character, you'll get an underscore for each.
       Your regular expression only matches a group of all of the characters, side-by-side, in the order you typed them and then it replaces the entire group with a single underscore.
       Oh, there's one other possible flaw. I think that the find utility creates lists of files in relatively large groups and then acts on them. If you change a directory that contains a file you want to change, it's possible that the change to the directory will not be reflected in the path to the file, causing a "file not found" error. A depth first search and acting only on the basename would eliminate that possibility.
    Hi Jeff,
       I recommend a command like the following:
    find -d /Users -regex ".[\:*?]." -exec echo 'mv "{}" "$(dirname "{}")"/"$(basename "{}" | sed '\''s/[\\:*?]/_/g'\'' )"' \; | sh
    That uses the same character class in the -regex option of the find command. That way, nothing will be invoked unless necessary. The method of creating the text of a complex command and using the -exec switch to echo that into a shell is an old trick from O'Reilly's UNIX Power Tools.
       I substituted a colon for a forward slash. As the path separator, the forward slash isn't a valid filename character on a UNIX system. However, old Apple tools, including the Finder, still use a colon as the path separator. Therefore the system presents the allowable character as a forward slash to Apple tools and a colon to UNIX tools. Thus using the colon in the command above will have the effect you want on files that the Finder says has a forward slash in the name.
    Gary
    ~~~~
       James Joyce -- an essentially private man who wished his total
       indifference to public notice to be universally recognized.
             -- Tom Stoppard

  • How to find Free disk space using Java program ?

    Hi friends,
    I need to find out the Free Hard disk Space to alert the user and send them mail if hard drive is about 85% full.
    i am developing databackup program in which i have to check it , if hard drive is fulled with 85% or remain left space is less email sent to user to notify and delete older backups.
    give me solution using java program...
    please
    Help me i need it in recent...

    Hi friends,
    I need to find out the Free Hard disk Space to alert
    the user and send them mail if hard drive is about
    85% full.
    i am developing databackup program in which i have to
    check it , if hard drive is fulled with 85% or remain
    left space is less email sent to user to notify and
    delete older backups.
    give me solution using java program...
    please
    Help me i need it in recent...

  • SCCM QUERY or VB SCRIPT to find Free Diskspace/ No of documents saved/last logon details (who and when)

    Can we please get a report showing all company laptops and the following information
    1. Disk space in use/Free and number of files/documents saved (doesn't matter if its Word or PDF, just give me the numbers)
    2. Whether they have any PST files stored on them
    3. The last login details (who and when)<o:p></o:p>
    I don't mind if its a VBscript or .batch file (but that should also extract the result in excel file) or i have SCCM 2012 server in place, and i can
    utilize this to get the result via querying.
    <o:p>I am Fairly new to SCCM2012 so please be nice if i ask any silly questions.</o:p>
    Thanks in advance,<o:p></o:p>

    1a: Disk space in use/Free: there are some default reports on your ConfigMgr 2012 site in the folder "Hardware - Disk"; those may be what you want.
    1b: number of files/documents saved: by default out of the box (unless you've changed it), "file inventory", also known as software inventory, is not enabled. This is for various technical and practical reasons.  However, if for your specific
    company you are required to scan for *.doc, *.xls, *.docx, *.xlsx, *.pdf, etc--you can certainly enable that feature.  Once enabled, you will be able to create custom reports to "count" the number of files on each computer.
    2: similar to 1b above, you could enable scanning for files which happen to be named *.pst.  This link is more advanced; but it's a more granular way of detecting who is using pst files, and where they are--whether or not they are local-->
    http://www.mnscug.org/blogs/sherry-kissinger/249-pstfinder
    3: "last login details who and when"--that is "sort of" recorded and available.  But I want to be cautious about telling you that it's available--because really it's your Active Directory domain controllers that *really* know when
    a username last logged in.  Remember, ConfigMgr is NOT meant to be an up-to-the-second reporting mechanism.  The reason last login details are recorded from a configMgr point of view is simply to assist in determining who the primary user of a machine
    is.  It's not, and is never meant to be, to help you see the exact time Bob logged into ComputerX.  It's more so that over weeks, the ConfigMgr Client can determine "hey, Bob is the one with the most console minutes on ComputerX, he's probably
    the primary user of ComputerX".
    Standardize. Simplify. Automate.

  • PowerShell Script For Finding Database Instance Names

    G'day
    I am trying to get information on a couple of dozen SQL database servers database instances - long story, but our DBA's do not have complete lists at the moment, and I need to find out this information.
    I have done a bit of work with PowerShell (and love it) version 3, however I do not know many SQL commands and was wondering if someone could point me in the right direction please.
    This is the code I have at the moment:
    Get-Service -ComputerName MSQLULTDBS04 | ?{$_.DisplayName -like "*SQL*"} | Select name,DisplayName,status
    It gets the information on the SQL Server install on the remote server.
    What I am trying to do however is get a list of the databases that are running on this server. Can someone help me out please?

    Hello Scott,
    Please have a look at TechNet ScriptCenter:
    Create Inventory of SQL Server in Network as Html
    It lists also all databases, but of course you need permissions to logon to that SQL Servers.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Script for Synnonym

    Anyone know of or have a good script for finding out all synonyms within a schema?

    look about
    select *
    from user_synonyms
    or all_synonyms
    ~
    pascal

  • Script to find/replace regular to Italic based on search terms in .txt

    Sorry for such a newbie post.
    I have been reading on JS scripts for find/replace.  I'm hoping develop a script or find one that is written that
    1. Looks into a .txt or any searchable file format, containing search terms
    2. Script will run on the entire Indesign document
    3. For any matching search terms script replace the style from regular to Italic, or from Bold to Bold/Italic. 

    Perfectly doable. Do you want to give it a go yourself?
    A few first thoughts (things I'd probably solve myself while writing the script):
    1. JS can read any file, but getting just the plain text out of an MS Word document is kind of ambitious -- even for me. Keep it simple: if your search text is nothing but a list of keywords or short phrases, write them out in a plain text file, one search item per line.
    2. With that I presume you mean not on one single continuous story, but all over the file -- including loose text frames, master pages, and what-have-you-got. Thass' easy, you can set the target for a Find or Replace operation with pin-point accuracy.
    3. .. This is the interesting part, actually.
    (a) Do you want to change the text style? That will set an override "+" for the modified text. It would be safer (wiser, etc.) to change it using a character style. (For the script it doesn't matter which method you use, this is just for the Future You who is going to edit this file in 6 months.)
    (b) If you do use a character style: what should happen if there already is one applied? Not bold or italic, but underline, for instance. Applying a new char style will override this one.
    (c) The naive approach (which I probably would have taken first) is to first search for each of the search terms, go over the 'found' list and test for each single entry if it's in regular or bold, then take appropriate action.
    A better approach -- without knowing anything else about this document -- could be to blindly use Replace to change ALL search terms in "Regular" to "Italic" and ALL search terms in "Bold" to "Bold Italic". It sure would be faster.
    (d) Just like in the interface, you can search for a word and 'change' only the formatting -- no need to change the text as well. And just like in the interface, you need to specify "whole words" and/or "case sensitive".

  • Script for Free Space in Datafiles

    Hi
    Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
    1)Is dba_Free_Space an exact indicator of how much space is available in a file.
    2) What is the significance of using blocks in vs using bytes.
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    Thanks in advance for you help.
    Script for checking backwards for free space at end of file
    REM Script is meant for Oracle version 9 and higher
    REM -----------------------------------------------
    set serveroutput on
    exec dbms_output.enable(1000000);
    declare
    cursor c_dbfile is
    select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
    from dba_data_files f,
    dba_tablespaces t
    where f.tablespace_name = t.tablespace_name
    and t.status = 'ONLINE'
    order by f.tablespace_name,f.file_id;
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    /* variables to check settings/values */
    dummy number;
    checkval varchar2(10);
    block_correction number;
    /* running variable to show (possible) end-of-file */
    file_min_block number;
    /* variables to check if recycle_bin is on and if extent as checked is in ... */
    recycle_bin boolean:=false;
    extent_in_recycle_bin boolean;
    /* exception handler needed for non-existing tables note:344940.1 */
    sqlstr varchar2(100);
    table_does_not_exist exception;
    pragma exception_init(table_does_not_exist,-942);
    begin
    /* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
    begin
    select value into checkval from v$parameter where name = 'recyclebin';
    if checkval = 'on'
    then
    recycle_bin := true;
    end if;
    exception
    when no_data_found
    then
    recycle_bin := false;
    end;
    /* main loop */
    for c_file in c_dbfile
    loop
    /* initialization of loop variables */
    dummy :=0;
    extent_in_recycle_bin := false;
    file_min_block := c_file.blocks;
    begin
    <<check_free>>
    for c_free in c_freespace(c_file.file_id)
    loop
    /* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
    block_correction := (0-mod(c_free.max_block,2));
    if file_min_block = c_free.max_block+block_correction
    then
    /* free extent is at end so file can be resized */
    file_min_block := c_free.block_id;
    else
    /* no more free extent at end of file, file cannot be further resized */
    exit check_free;
    end if;
    end loop;
    end;
    /* check if file can be resized, minimal size of file 16 blocks */
    if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
    then
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('cannot be resized no free extents found');
    dbms_output.put_line('.');
    else
    /* file needs minimal no of blocks which does vary over versions */
    if file_min_block < 16
    then
    file_min_block := 16;
    end if;
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
    /* below is only true if recyclebin is on */
    if recycle_bin
    then
    begin
    sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
    execute immediate sqlstr into dummy;
    if dummy > 0
    then
    dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
    dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
    dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
    end if;
    exception
    when no_data_found
    then null;
    when table_does_not_exist
    then null;
    end;
    end if;
    dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
    dbms_output.put_line('.');
    end if;
    end loop;
    end;
    Example output for Oracle version 9 and higher:
    Tablespace: TEST Datafile: /oradata/v112/test01.dbf
    cannot be resized no free extents found
    Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
    current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
    SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
    Tablespace: USERS Datafile: /oradata/v112/users01.dbf
    current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
    Extents found in recyclebin for above file/tablespace
    Implying that purge of recyclebin might be needed in order to resize
    SQL> purge tablespace USERS;
    SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K

    Hi
    Got the below script from metalink [130866.1] to identify free space within a data file.Couple of questions
    1)Is dba_Free_Space an exact indicator of how much space is available in a file.
    2) What is the significance of using blocks in vs using bytes.
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    Thanks in advance for you help.
    Script for checking backwards for free space at end of file
    REM Script is meant for Oracle version 9 and higher
    REM -----------------------------------------------
    set serveroutput on
    exec dbms_output.enable(1000000);
    declare
    cursor c_dbfile is
    select f.tablespace_name,f.file_name,f.file_id,f.blocks,t.block_size
    from dba_data_files f,
    dba_tablespaces t
    where f.tablespace_name = t.tablespace_name
    and t.status = 'ONLINE'
    order by f.tablespace_name,f.file_id;
    cursor c_freespace(v_file_id in number) is
    select block_id, block_id+blocks max_block
    from dba_free_space
    where file_id = v_file_id
    order by block_id desc;
    /* variables to check settings/values */
    dummy number;
    checkval varchar2(10);
    block_correction number;
    /* running variable to show (possible) end-of-file */
    file_min_block number;
    /* variables to check if recycle_bin is on and if extent as checked is in ... */
    recycle_bin boolean:=false;
    extent_in_recycle_bin boolean;
    /* exception handler needed for non-existing tables note:344940.1 */
    sqlstr varchar2(100);
    table_does_not_exist exception;
    pragma exception_init(table_does_not_exist,-942);
    begin
    /* recyclebin is present in Oracle 10.2 and higher and might contain extent as checked */
    begin
    select value into checkval from v$parameter where name = 'recyclebin';
    if checkval = 'on'
    then
    recycle_bin := true;
    end if;
    exception
    when no_data_found
    then
    recycle_bin := false;
    end;
    /* main loop */
    for c_file in c_dbfile
    loop
    /* initialization of loop variables */
    dummy :=0;
    extent_in_recycle_bin := false;
    file_min_block := c_file.blocks;
    begin
    <<check_free>>
    for c_free in c_freespace(c_file.file_id)
    loop
    /* if blocks is an uneven value there is a need to correct with -1 to compare with end-of-file which is even */
    block_correction := (0-mod(c_free.max_block,2));
    if file_min_block = c_free.max_block+block_correction
    then
    /* free extent is at end so file can be resized */
    file_min_block := c_free.block_id;
    else
    /* no more free extent at end of file, file cannot be further resized */
    exit check_free;
    end if;
    end loop;
    end;
    /* check if file can be resized, minimal size of file 16 blocks */
    if (file_min_block = c_file.blocks) or (c_file.blocks <= 16)
    then
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('cannot be resized no free extents found');
    dbms_output.put_line('.');
    else
    /* file needs minimal no of blocks which does vary over versions */
    if file_min_block < 16
    then
    file_min_block := 16;
    end if;
    dbms_output.put_line('Tablespace: '||c_file.tablespace_name||' Datafile: '||c_file.file_name);
    dbms_output.put_line('current size: '||(c_file.blocks*c_file.block_size)/1024||'K'||' can be resized to: '||round((file_min_block*c_file.block_size)/1024)||'K (reduction of: '||round(((c_file.blocks-file_min_block)/c_file.blocks)*100,2)||' %)');
    /* below is only true if recyclebin is on */
    if recycle_bin
    then
    begin
    sqlstr:='select distinct 1 from recyclebin$ where file#='||c_file.file_id;
    execute immediate sqlstr into dummy;
    if dummy > 0
    then
    dbms_output.put_line('Extents found in recyclebin for above file/tablespace');
    dbms_output.put_line('Implying that purge of recyclebin might be needed in order to resize');
    dbms_output.put_line('SQL> purge tablespace '||c_file.tablespace_name||';');
    end if;
    exception
    when no_data_found
    then null;
    when table_does_not_exist
    then null;
    end;
    end if;
    dbms_output.put_line('SQL> alter database datafile '''||c_file.file_name||''' resize '||round((file_min_block*c_file.block_size)/1024)||'K;');
    dbms_output.put_line('.');
    end if;
    end loop;
    end;
    Example output for Oracle version 9 and higher:
    Tablespace: TEST Datafile: /oradata/v112/test01.dbf
    cannot be resized no free extents found
    Tablespace: UNDOTBS1 Datafile: /oradata/v112/undotbs01.dbf
    current size: 9384960K can be resized to: 106496K (reduction of: 98.87 %)
    SQL> alter database datafile '/oradata/v112/undotbs01.dbf' resize 106496K;
    Tablespace: USERS Datafile: /oradata/v112/users01.dbf
    current size: 328960K can be resized to: 117248K (reduction of: 64.36 %)
    Extents found in recyclebin for above file/tablespace
    Implying that purge of recyclebin might be needed in order to resize
    SQL> purge tablespace USERS;
    SQL> alter database datafile '/oradata/v112/users01.dbf' resize 117248K

  • Can't find free space for Shared Memory (Size=83739 KB)

    Hello All,
              I have an issue. i am unable to bring up the server. It is ABAP system.
    dev_w0 log file show me memory error.
    I Fri May 01 10:11:55 2009
    I  *** ERROR => [MapOsShm] Can't find free space for Shared Memory (Size=83739 KB)
                   [shmnt.c      2174]
    I  *** ERROR => [AttachOsShm] MapViewOfFile(Key=62,Handle=0x000003FC) failed with Err=0
                   [shmnt.c      2174]
    I  *** ERROR => ShmCreate: Attach (62,85748608,2) failed [shmnt.c      422]
    Can some body help me with it.
    Thanks and regards
    Kiran

    I am running into the same issue. What exactly solved your problem?
    I will really appreciate any info., around this.
    i am trying to install CE 7.2 Developer Workplace on Windows 32 bit.
    Saurabh

  • HOW to find out the tablespace space utilized by a patch after applying the

    someone has already applied the patch in test env before recording the tablespace size , so I cannot find out the figure in test env.
    So is there any general practice or general guidelines on it?
    hOW to find out the tablespace space utilized by a patch after applying the patch?
    Thanks & Regards,
    Sree.
    Edited by: 846579 on Mar 22, 2011 10:50 PM

    I think there is no direct way to determine what tablespace is utilized by a patch from the README file. You could check the content of the patch file and see what modules are affected (assuming there are changes and the database level), then query DBA_USERS (DEFAULT_TABLESPACE column) for those schemas which are updated by a patch. Or, you could check the size of the tablespaces before and after applying the patch and you will determine what tablespaces have been utilized (provided that the application services are down, and none of the application users is connected to the application).
    Thanks,
    Hussein

  • Free disk space in Finder vs Terminal df command

    i am in process of writing a shell script to backup our data.
    before starting the backup process, i am checking how much space is left on the disk:
    terminal> df -k /my_data_directory/
    Filesystem   1024-blocks      Used Available Capacity  Mounted on
    /dev/disk0s2   244781464 173055384  71470080    71%    /
    this states 71.47 GB free space on /
    however, the Finder reports 96.17 GB free space on Macintosh HD (which is also mounted on /).
    where does that difference come from? how can i "calculate" the real free disk space?

    tuscan wrote:
    do i get your answer right:
    this means the Finder is reporting an amount of free space one can never use?
    its number includes those bytes that are unused in used disk blocks?
    e.g. say a block is 8k an my specific disk, and i'm saving a file with 1k of text.
    the Finder would report 7k of these 8k as free space?
    while df takes the whole 8k block as "used"?
    As jsd2 points out, it is more complicated than that. I don't have local snapshots running on my machine but I still have a significant discrepancy, although not as large as yours.
    df is a fast tool and only looks at blocks. The Finder does more work and keeps track of file sizes and, apparently, the potential to delete them. But if you had a one-byte file, those other 4095 bytes wouldn't necessarily be wasted. You could write another 4095 bytes to that file without losing any disk space.

  • I have an external hard drive which has my i-photo on it & some movies from i-movie that I have on disk now. But for some reason my ehd has a caution symbol on it & I can't move my event to free up space on my hd so that I can export i-movie events. Help!

    I have an external hard drive which has my i-photo on it & some movies from i-movie that I have on disk now. But for some reason my ehd has a caution symbol on it & I can't move my event to free up space on my hd so that I can export i-movie events. Help!

    Usually the caution symbol means that it's formatted as a PC compatible format like NTFS or most likely FAT32. For iMovie to use it the ehd must be formatted Mac OS Extended. Then iMovie will show it without the caution symbol and you can drag/drop open any Event/Project from that hard drive.
    To find out if it's formatted as PC:
    Go to the desktop, holding down the Control key click on that ehd and in the pop-menu choose 'Get Info'
    Under Format: It will say whether or not it's Mac OS Extended (Journaled). The only way to undo a PC formatted ehd would be to copy everything off of it first, Erase/Format the drive using Disk Utility in the Applications>Utilities folder on your Mac, choosing the Mac OS Extended (Journaled) format in the pull-down menu there.

Maybe you are looking for