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;

Similar Messages

  • 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

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

  • How to find free space in datafiles of perticular schema?

    hai,
    whats the query to find out free space in datafiles and index files related free space for perticular schmea?
    Regards
    dba

    There are lots of scripts available on Metalink which report free space in tablespaces/datafiles.
    Note: 1019999.6 - Script: To List Tablespace, Datafiles and Free Space
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=1019999.6
    Note: 145531.1 - How to Determine Which Tablespaces Do Not Have Enough Free Space
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=145531.1

  • Lion takes long time to find free space after emptying trash

    After emptying the trash, I've noticed that Lion does not see the additional free space until after doing a reboot, and even after that it takes a long time for it to find all the new free space.  Anybody know what's wrong with the trash system?

    Absolutely nothing is wrong with it.  See Missing disk space in Lion.

  • Solaris volume manager ; finding free space

    Hello
    Is there a way to find out the space available in a metadevice for creating new soft partions?
    I am looking for the equivalent of the following vxvm commands
    vxdg free
    vxassist maxsize
    Thanks in advance

    If it is indeed showing as free space have you tried just extending your existing volume instead of making a new one?
    You can right click your existing volume in disk manager and say extend partition and just next through the wizard. It should auto set all the values to consume is all the space.
    Option 2 is to use the command line utility called diskpart. Go to start, type cmd. After the command prompt is open you will type diskpart.
    First list the disks by typing "list disk" then select the disk you wish to work with. Example "select disk 1".
    Then list the volumes, similar to disk you do "list volume". You then select the desired volume you want to extend. Select the 58.8 GB volume similar to selecting the disk. After the volume is selected you will type "extend" and
    it will grow the volume into the free space.

  • How to find free space in a Tablespace?

    Hi,
    I have a limited access to objects in my database ( do not have access to many tables).
    I have been allocated 300GB of size in my tablespace which allows me to create my objects.
    Now, I want to find out how much of this tablespace size allocated to me have been used up. I do not have access to dba_data_files or dba_segments.
    Is there a way out for me? Could anyone show me a way please?

    This query will give you the required information but it makes use of DBA tables.
    SELECT B.TABLESPACE_NAME, TBS_SIZE SIZEGB, A.FREE_SPACE FREEGB
    from  (select tablespace_name, round(sum(bytes)/1024/1024/1024 ,2) as free_space
           from dba_free_space
           GROUP BY TABLESPACE_NAME) A,
          (select tablespace_name, sum(bytes)/1024/1024/1024 as tbs_size
           from dba_data_files
           group by tablespace_name) b
    where a.tablespace_name(+)=b.tablespace_name;
    However, you said that you are aware of your tablespace details so the above query can be modified to get the free space in your tablespace. Now I am using user_frees_space and not dba_free_space. Generally user* tables are and should be made accessible to the users.
    select  tablespace_name, round(sum(bytes)/1024/1024/1024 ,2) as free_space
    from    user_free_space
    where   tablespace_name = 'Your tablespace name'
    GROUP BY TABLESPACE_NAME;
    Ishan

  • How to find free space in an ArrayList...

    Hi,
    I have an ArrayList with data randomly assigned to different indexs of the ArrayList.
    I want to find out where the "gaps" are within the ArrayList... For Example There would be data in index 0,1,2,3,5 but not in index 4 . How would I go about finding this information.
    Thanks
    Chris

    jwenting wrote:
    kajbj wrote:
    Praveen_Forum wrote:
    I don't think we have to look into the free space's for ArrayList, as it is a dynamic growing arraylist you can just keep on adding the stuff in it takes care of filling all the empty spaces
    I am i right?No, it will not fill a gap.in fact it will, after a fashion.
    When you remove an item the remaining items are reshuffled to close the gaps.
    When you try to insert an item beyond the last position (so at list.size()+2 or greater) you will get an error, and the insert will fail.I was more thinking of a situation like this:
            strings.add("One");
            strings.add("Two");
            strings.add("Three");
            strings.set(1, null);
            System.out.println(strings);The element at index 1 will be null (a gap in my view), since remove won't cause a gap.
    Kaj

  • How to find free space in ASM

    Hi experts,
    we use oracle 11.1 rac and database with asm in redhat.
    I copied two query from online.
    query 1 as
    select name,total_mb,free_mb from v$asm_diskgroup;
    NAME TOTAL_MB FREE_MB
    DATA1 511993 132092
    FLSDISK1 1638394 712233
    but query 2 shows there are no space in ASM diskgroup
    QL> select d.name disk_name,g.name group_name,d.path,d.total_mb,d.free_mb
    2 from v$asm_disk d, v$asm_diskgroup g
    3 where d.group_number = g.group_number (+)
    4 ;
    DISK_NAME GROUP_NAME PATH TOTAL_MB FREE_MB
    FBDISK1 FLSDISK1 ORCL:FBDISK1 1638394 0
    DATADISK1 DATA1 ORCL:DATADISK1 511993 0
    which query do I need to use to check free space in asm diskgroup?
    Thanks
    JIm

    Hi,
    If you're looking freespace in diskgroup i believe you can use the first one
    second script is looking freespace per each disk
    Cheers
    FZheng

  • Sql query to find the space in between the sentense

    hi,
    can anybody tell me the query to find the space in between the data
    chandan

    Not sure what you mean, but you might want to take a look at INSTR, like in
    instr (txt, ' ')

  • Help! Used "Secure Delete Free Space" on Spring Cleaning App...

    Okay, so I don't know a whole lot about computers or anything. Someone told me to use Spring Cleaning to delete free space on my macbook pro because that would make my computer more secure and wouldn't allow any deleted files to be recovered. So I did, and now I have zero KB left of space. I guess I should have known that "delete free space" literally meant delete all of your free space, but why would anyone tell me to do that? Now I have no room to add anything to my computer. So I need to know how to reverse this, and if I can't, what my options are other than get an external hard drive and suck it up.

    Hello c:
    I do not like third-party applications that affect data or system files - for a variety of reasonably good reasons.
    For future reference, use disk utility to do what you wanted to accomplish. You simply highlight your disk, click on erase, and then click on _erase free space._
    Barry

  • Finding Free Space

    I used Disk Utility and erased all my free space. It entered "zeros" into the free space so cannot save anything anymore. How do I get rid of these "zeros"?

    When you elect to erase free space, Disk Utility creates a file that takes up all the free space, then writes zero's to it. If the process is interrupted or doesn't complete normally, that file is left on the system and all of a sudden there's no more space available on the disk.
    To get rid of the file, if you have a program like Disk Inventory X or an older version of Whatsize, you can see all the files and easily identify and delete the file (as I recall it's a hidden file). If you can free some space up, you can download the old version of Whatsize from http://www.free-mac-software.com/whatsize/

  • Pls. help, SQL script page problem

    Hi,
    Im using the Hands On Oracle Database 10g Express Edition for Linux. Im in chap06 already p. 218. I just uploaded the SYSMGMT1 script. After that I Clicked the script's icon but I cannot see any SQL DDL commands inside. Nothing happened. It said in the book that I supposed to see and browse the SQL DDL commands that make up the script. I tried to click RUN, nothing happened either. Is there some kind of a bug in my System? Pls. help me because I cannot continue this chapter's exercise if I cannot solve this first problem that I encountered here in chap06. Any help from the guys outhere is really greatly appreciated. Thank you.
    respectfully waiting,
    Len

    Hi, did you ever get a solution to this because I am having exact same problem - I cannot see the scripts if I upload them nor can I type them in from scratch as the area for seeing/editting the script doesn't seem to be accessible.

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

  • HELP!!! No free space since Photos transition

    Long story short- Photos is somehow locking up space on my iPad.
    In "usage" on the iPad, it says "Photos and camera" takes up 31.2GB.
    In the subdivision under that, 30.5GB are "synced from iTunes Library".  My camera roll is empty, and there are only 678MB in my Photo Stream.
    BUT
    In the capacity bar in iTunes, it says Photos take 3.1GB (for 20,000 photos, so obviously that is wrong), and "other" is 29.5GB. And the "other" gets bigger every time I sync.  I keep trying to make a backup so I can erase/restore- but it won't complete the backup since there's not enough space!
    And the killer-
    in iTunes I have photo sync TURNED COMPLETELY OFF.  There should be ZERO pix synced from my iPhoto library!  Not 30GB!
    When I open the photos app, there are lots of pix.  I can't tell if it's 20K, but it might be.
    So how do I delete them???
    I can't delete them from the iPad.  I thought turning off photo sync should remove them all.  But it didn't!
    And- same exact situation is happing on my phone. This all started after the OS 10.3 update (changing iPhoto to Photos) yesterday.

    I have same problem, Apple is focusing on its iCloud storage and broke syncing, again. Do this:
    Ypu can start Image Capture and try to delete pictures there, it did not solve my problem so:
    You do not have to Restore your device, you need to download PhoneView or any other application what can access your iThing storage. When you click on Photos under MEDIA you will see no photos however when you go to DATA, PhotoData you will be able to find them. Just delete everything in that folder, also delete everything in DCIM and Photos, and reboot your device. iOS will recreate all the folders a .sqlite etc. The data is cache what iTunes can not clear.
    If you sync it again it will corrupt again.

Maybe you are looking for

  • Warning message on excess delivery

    hi all from which custumization process we  can decide whether the system give a warning message or to stop the process as and when the excess qty is being confirmed. regards

  • Table to find previous tcode ?

    Hi. can any one plz tell me table to find previous tcode? how can we find previous tcode which we entered in sap? Thanks praveen

  • Error occured when using javap (Java Class File Disassembler)

    Hi, I have tried to use Java Class File Disassembler by using javap and i'm getting the error shown below, C:\> javap abc.class ERROR: Could not find abc.class abc.class present in C:\ drive. Please let me know how to solve the problem Thanks in Adva

  • OID Provisioning issue

    I have a case where a user did not get updated in OID when his account got modified in OIM. This lead to a data mismatch between OID and OIM. Can I write a task to send his info into OID. Thanks M

  • ITunes on Mac won't play transferred songs purchased by same account on PC

    I have recently transferred my iTunes library from a PC to a Mac (using my iPod as a hard drive). However, when I open up iTunes on my Mac, I am told that certain songs (all of the ones purchsed from the Music Store from the PC) are not authorized to