Script to calculate space usage at the database level.

Hi,
Can someone provide me a script to calculate the Total space, Used space and Free space for all tablespaces within a database??
I have been trying to use the below combinations in my queries and both provide different results..
1) dba_data_files & dba_free_space
select t.tablespace, t.totalspace as " Totalspace(MB)", round((t.totalspace-fs.freespace),2) as "Used Space(MB)", fs.freespace as "Freespace(MB)", round(((t.totalspace-fs.freespace)/t.totalspace)*100,2) as "% Used", round((fs.freespace/t.totalspace)*100,2) as "% Free" from (select round(sum(d.bytes)/(1024*1024)) as totalspace, d.tablespace_name tablespace from dba_data_files d group by d.tablespace_name) t, (select round(sum(f.bytes)/(1024*1024)) as freespace, f.tablespace_name tablespace from dba_free_space f group by f.tablespace_name) fs where t.tablespace=fs.tablespace order by t.tablespace;
2) dba_extents & dba_free_space
select t.tablespace, t.totalspace as " Totalspace(MB)", round((t.totalspace-fs.freespace),2) as "Used Space(MB)", fs.freespace as "Freespace(MB)", round(((t.totalspace-fs.freespace)/t.totalspace)*100,2) as "% Used", round((fs.freespace/t.totalspace)*100,2) as "% Free" from (select round(sum(d.bytes)/(1024*1024)) as totalspace, d.tablespace_name tablespace from dba_extents d group by d.tablespace_name) t, (select round(sum(f.bytes)/(1024*1024)) as freespace, f.tablespace_name tablespace from dba_free_space f group by f.tablespace_name) fs where t.tablespace=fs.tablespace order by t.tablespace;
Thanks in advance,
regards,
Arul S

-- check the total,used and free space in tablespaces
select     a.TABLESPACE_NAME,
     a.BYTES MB_total,
     b.BYTES MB_free,
     b.largest,
     a.BYTES-b.BYTES MB_used,
     round(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used
from
          select      TABLESPACE_NAME,
               sum(BYTES)/1048576 BYTES
          from      dba_data_files
          group      by TABLESPACE_NAME
     a,
          select      TABLESPACE_NAME,
               sum(BYTES)/1048576 BYTES ,
               max(BYTES)/1048576 largest
          from      dba_free_space
          group      by TABLESPACE_NAME
     b
where      a.TABLESPACE_NAME=b.TABLESPACE_NAME
order      by ((a.BYTES-b.BYTES)/a.BYTES) desc;
Regards
Asif Kabir

Similar Messages

  • You do not have enough free disk space to create the database

    Hello,
    When I try to create a database, I have this error message:
    You do not have enough free disk space to create the database. You need at least 1428480 kB on /opt/oracle, you have only 1179648 kB available, please alocate more free disk space.*
    When I run *# df -h* I have:
    /dev/mapper/VolGroup00-LogVol09
    5.7G 4.3G 1.2G 79% /opt/oracle
    and
    /dev/mapper/VolGroup00-LogVol10
    486G 542G 262G 68% /oracle_data
    and with vgdisplay I have:
    Alloc PE / Size 29772 / 930.38
    Free PE / Size 0 / 0
    My info is:
    Redhat Linux server release 5.8
    Oracle 11.2.0
    I do not know how to solve this.
    Please help me
    Thank you
    Frank

    976847 wrote:
    Please... like reading exercise, read again my last post and you will understand the information.
    1179648 kB available space is comparable with 1.2GB. Both are the available space.
    Thank you for your help.From the error you reported in your original post
    You do not have enough free disk space to create the database. You need at least <font color="red" size="4">1428480 kB</font> on <font color="red" size="4">/opt/oracle</font>, you have only <font color="red" size="4">1179648 kB</font> available, please alocate more free disk space.
    SQL> select 1179648 i_have, 1428480 oracle_needs,
      2         1179648 - 1428480 i_am_short
      3  from dual;
        I_HAVE ORACLE_NEEDS I_AM_SHORT
       1179648      1428480    -248832So, yes, both numbers report the available space in slightly different terms, but what you need to be concerned about is how much Oracle thinks you neeed to have, which is <font color="red" size="4">more</font> than you actually have on /opt/oracle.
    John

  • Updates to the table from the database level.

    Hi Dear All,
    If we do some updates to the table at the Database Level, like i deleted some records from the table at the Oracle level. But I'm still able to see the same deleted records from the Data Dictionary(SE11) at the application level.
    Can you pl explain the mechanism, that how it is possible and why.
    best regards
    Mahesh

    transparent tables store data directly....if you delete some data from transparent tables, the same is reflected in the database (oracle) but the reverse is not true...if you modify the database table contents directly...the dictionary table remains intact...
    transparent tables have a one-to-one relationship with the database tables....
    hope that clarifies a bit....
    (somebody correct me if i am horribly wrong)

  • User defined tables:  amending Index on the database level. Opinions???

    Hi everybody who has some spare time to read my stuff
    I had a problem that some of you might have had. I have a user defined table, let’s call it ProductTypes. Now system by default creates two columns in this table, one is Code (primary key) and another is Name (Index). I have added third column called Department. Now, if I wanted to add the following data (see bellow) to the table I would have had a constraint violation message pointing me out that I have problems with indexing.
    Code, Name, Department
    1, Cream, Fragrances
    2, Cream, Beauty Products
          ^^
    I could thing of couple workarounds of this problem
    1. Is to duplicate Code into Name and storing rest of the data using user columns
    Code, Name, Product Name, Department
    1, 1,Cream, Fragrances
    2, 2, Cream, Beauty Products
    This approach isn’t very convenient as it requires UI development should we decide to attach this table to the Item master data form in a form of combo box.
    2. Is to amend Index on the database level. Initially, the index KProductTypes_Name consisted of only one column Name, what I have done is added another column which is Code to indexing. I don’t see how this can harm database consistency or damage the core system.  Please correct me if I am wrong.
    Another way of amending index in order to solve my problem could be choosing ignoring duplicate values option for column Name.
    Please let me know what are your thoughts.
    Best wishes

    > Why don't you try adding a trigger 'instead of
    > insert' where code = max(code)1 and name=max(name)1
    > and use only user columns for your data. This
    > provided you know SQL basics.
    in this scenario we would have to do UI SDK development for the output and going to have an extra column with meaningless data in it.

  • Row-level security at the Database level

    We need Row-level security at the Database level, where the user who logs in to Crystal reports, should be able to fetch only those rows from the database that he is entitled to see. For this, the login name of the user is passed to a stored procedure which sets the context of the DB session and restricts the data retrieved.
    We are not looking for row-level security where the data is first retrieved and then filtered based on the user login name. However, we are definitely looking for a way to set a context for a database session based on the user login name, even before we start fetching data. So effectively, the user who logs in will fetch only those rows which he is supposed to see.
    Issue:
    We face a problem of not being able to pass a variable (something like 'BOUSER' for BO which works, whereas, 'CurrentCEUserName' for Crystal Reports, which doesn't work), to the database stored procedure to set the context.
    Please let us know if we can use 'CurrentCEUserName' variable in Crystal in the same way as 'BOUSER' is used in ConnectInit for BO? We would like to know how we could pass any variable in Crystal Reports which holds the user login information to a stored procedure.
    Also, please suggest alternate ways to achieve this security restriction, if any.

    Hi
    A previous database had a personnel table with their station name, district and region, with a field holding their logon name.  We also had an activity table with the fields referring to the activity, and a field of Station, district and region it occured in.
    By linking the individual rows in an activity table to the personnel table on the station name field, we then used the CurrentCEUserName to filter on the personnel.  This returned only the records in the activity table where the station the activity took place at was the same as the station associated with the selected personnel who has logged on.
    The additional bonus was if we linked it on District or region we had the same result but at a greater level. ie all activity in the logged on personell's District or if linked on region, then their region.
    The personnel table was maintained by the system administrators, so maintenance was low.
    I hope this helps.
    Kevin

  • Script to fetch the script of a existing view from the Database

    Hi,
    How to fetch a existing view's information (SCRIPT) dynamically from the database.
    Thanks in advance
    Regards,
    Mr.R

    I did not post to ask this question.
    I try on the command line on SQL it prompts the first line of the script. How is the rest of the script?
    QL> select dbms_metadata.get_ddl('VIEW','MY_VIEW') from dual;
    BMS_METADATA.GET_DDL('VIEW','MY_VIEW')
    CREATE OR REPLACE FORCE VIEW "MY_USER"."MY_VIEW" ("USER_ID *<== How to fetch the rest of the script.*

  • Enable single item recovery with two retention settings at the database level.

    Hello All,
    We have an Exchange 2010 SP3 RU4 environment and planning on moving from third party archives solution to Native Exchange archives for cost reduction purposes, upgrading to Exchange 2013 to benefit from added in place features is not within scope at
    this stage.
    We are looking at implementing the following steps and want to know if it will work:
    1-Create archive DB(s) as per our usage and growth projections
    2-Enable archives for all our users and migrate current archive content to it.
    3-Create Retention Tag/Policy to move all records from live to archive "Age limit for retention" 90 days (no retention tags on the policy)
    4-Enable Single Item recovery for all of our users (script the same to run twice daily to enable SIR for newly created accounts)
    5-Set the "Keep Deleted Items" on the Live DB(s) to 90 days and the Archive DB(s) to 7 Years
    6-We are NOT using Legal Hold or plan to use it except on per as need basis
    Are we accomplishing the following:
    1-Items are automatically archived after 90 days
    2-Items archived now have a 7year retention based on the "keep deleted items" set for the archive DB(s)
    3-Items copied back to the live mailbox by a user will be returned to the archive database the next time the folder assistant runs against this user account (based on load or if run manually)
    4-Hard deleted items by a user is recoverable as long as the email record is within the retention period set at the database where it resides.
    5-Hard deleted items are recoverable using MFCMapi or by a restore.
    6-Items are permanently purged on the archive DB(s) after 7 years.
    Any input, ideas, recommendations, clarifications would be greatly valued and appreciated.  
    Ash

    Thanks CodexCZ,
    So, SIR will "kind of" do the same as the retention tag except I can use different durations based on the limits on each DB? am I correct?
    thanks again.
    Ash

  • HT204022 how can i manage the space usage of the applications on my icloud account?

    I would like to see what it's taking the space on my icloud account so i can manage it's usage, but i don't know where to go to do it.

    Settings>iCloud>Storage & Backup>Manage Storage.  See http://support.apple.com/kb/ht4847.

  • Why is my Macbook pro with OS lion prompting me my startup disk almost full when i have deleted many files, photos and videos? Even thrashing them doesn't help. There seems to be an automatic space usage in the background

    I have deleted many unwanted files and apps and yet the available space keeps depleting every time i am using my Macbook Pro. I believe under the OS 10.7.4 one of the features is it backups or has backgrounding features which uses memory. Sometimes even when i hv 8GB space after using my Macbook Pro for say 2hrs surfing internet and using Pages which has a "Save Version" feature suddenly my 8GB goes down to 300+MB only and it starts prompting me "My Startup Disk is almost full" once it reaches 1GB space left. How can i get more space.... Please someone can help me? Do i need to re-format my hardisk??!! Any help out there is greatly appreciated.
    My original HD is 320GB. And i don't hv too many Apps installed. I do have abt 50-70apps. I do have many photos and videos stored in iPhoto's Library though.

    One thing I've noticed is that a shared tab pops up when I open the finder under "favorites" with a random connection. It's called hp68b... None of my friends that I live with have this and we all use the same internet. Two days ago when I would click it and click get info, it said it was a pc. When I checked it today it said it is a "sharepoint" and looks like a harddrive.
    I took it too the store after i spilt water on it but when I got it back it ran perfectly fine. I don't know a lot about computer so if somebody could help me. It says I'm connected to it and I can't disconnect or delete it. I don't know if the guy at the computer store put something in my computer and is sharing all my files.

  • Security in essbase at the database level

    i need to edit users ability to access various databases within an application in essbase. the user has been provisioned in shared services to the app, but, it appears to further restrict particular databases, that has to be done in essbase. right? i apparently don't have that "role" assigned to me. what is that "role" that i need to have assigned to me?

    Hi
    It sounds like you need to create specific Essbase security filters, these are created in Essbase and can then either be assigned to users in Essbase or via Shared Services. Filters are specific to databases so you can have different access to different databases or none at all to some.
    Take a look at the Essbase database administrators guide.
    Hope this helps
    Stuart

  • Oracle 11.2.0.3 - Lob space usage

    Hi Everyone,
    I would like some advise about how to interrupt LOB space usage given the following statistics. And would appreciate any feedback on whether my understanding of the following is correct:
    We have a table with BLOB column which is located on a LOB segment.
    This the DDL to create the table and the LOB:
    CREATE TABLE BLOB_TEST
      TEST_ID      NUMBER  NOT NULL,
      TEST         BLOB
    LOB (TEST) STORE AS (
      TABLESPACE  USERS
      ENABLE      STORAGE IN ROW
      CHUNK       8192
      RETENTION
      NOCACHE
      LOGGING
          STORAGE    (
                      INITIAL          64K
                      NEXT             1M
                      MINEXTENTS       1
                      MAXEXTENTS       UNLIMITED
                      PCTINCREASE      0
                      BUFFER_POOL      DEFAULT
                      FLASH_CACHE      DEFAULT
                      CELL_FLASH_CACHE DEFAULT
    TABLESPACE USERS
    RESULT_CACHE (MODE DEFAULT)
    PCTUSED    0
    PCTFREE    30
    INITRANS   10
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    The statistics for this table is as follows:
    The size of the test blob is:
    A.
    select sum(dbms_lob.getlength (test))/1024/1024 mb  from BLOB_TEST
    = 4860 mb
    Space above HWM ( using dbms_space.unused_space):
    B.
    TOTAL_BLOCKS = 778368
    TOTAL_BYTES = 6376390656
    UNUSED_BLOCKS = 0
    UNUSED BYTES = 0
    LAST_USED_EXTENT_FILE_ID = 12
    LAST_USED_EXTENT_BLOCK_ID = 3383296
    LAST_USED_BLOCK = 8192
    Space below HWM (using dbms_space.used_space):
    C.
    TOTAL_BLOCKS = 778368
    TOTAL_BYTES = 6376390656
    UNUSED_BLOCKS = 0
    UNUSED BYTES = 0
    LAST_USED_EXTENT_FILE_ID = 12
    LAST_USED_EXTENT_BLOCK_ID = 3383296
    LAST_USED_BLOCK = 8192
    Unformatted Blocks = 0
    FS1 Blocks = 0
    FS2 Blocks = 0
    FS3 Blocks = 0
    FS4 Blocks = 0
    Full Blocks = 777114
    Using the above, this is what I'm interrupting and need your help on this to make sure that this is right.
    From A, the total size of the test blob data is:  4806 MB.
    From B, the amount of free space ABOVE HWM is 0. This is because there is 0 in the unused_blocks.
    From C, the amount of free space BELOW HWM is 0, because all the FS's are 0 and so is UNUSED_BLOCKS as well.
    The amount of full blocks = 777114 blocks. This means that 615168 blocks (from 4806MB) is for data.  The rest is for undo space as there is 0 for free space?
    In addition to this, 778368 - 777114 = 1254 blocks = 9.8 mb (approx) of? I'm not sure what is this.
    Am I on the right track here?
    Thanks

    Pavel wrote:
    Hello!
    I have Oracle 11.2.0.3 on Aix 64bit installed and see symptoms of bug 13443029 ,
    have I downgrade to 11.2.0.2 to appling the patch for fixing this bug ?
    README for *13443029*
    Patch Details
    Oracle Database 11g Release *11.2.0.2.0*
    ORACLE DATABASE Patch for Bug# 13443029 for AIX5L Platforms
    Released: 13 Jan, 2012Thanks and regards,
    PavelOpen SR . you will get help and send you patch if they think its need that .

  • Not able to finish the database creation 10gR2

    Friends,
    OS: RHEL As 4.8
    DB: 10gR2 (10.2.0.1)
    After finishing installation the dbca started when i click the final finish....
    DBCA throws the error....
    you do not have enough free disk space to create the database.
    you need at least 14738432 KB on /tmp/, you have only 4689920 KB available
    please allocate more free disk space.i have allocated 5 gb for /tmp ..... is it not enough? am i have to allocate 15 gb as specified above?
    thanks

    Hi,
    i didnt set it to /tmp.....when i do the runinstaller from cd....automatically its going to /tmp.....
    so how can i change this?You can try copying oracle database software to hard disk and then give another try in the install.
    Check thisd out:
    http://download.oracle.com/docs/cd/B19306_01/install.102/b15660/inst_task.htm#CIHBADCC
    And please don't forget to double check "Required Software Directories" at:
    http://download.oracle.com/docs/cd/B19306_01/install.102/b15660/pre_install.htm#sthref357
    Good luck!
    Marcello M.

  • MacBook Disk Space Usage

    Hi,
    Has anyone found a utility that can be used to locate disk space usage on the MacBook? I would like to find out what files are eating up my disk space and would prefer to not have to use UNIX commands to accomplish this. I need to delete something off my computer but need help to locate the culprit. Any help is appreciated.
    Thanks

    Use a program such as WhatSize or Disk Inventory X to determine where the space is being used.
    (38758)

  • Find the size of the database

    Hi gurus,
    Can some one suggest me in finding the size of complete database and the free space left in the database .
    as i am doing the refresh just need to gather the statistics .
    thanks

    790072 wrote:
    Hi gurus,
    Can some one suggest me in finding the size of complete database and the free space left in the database .
    as i am doing the refresh just need to gather the statistics .
    thanks
    1  select round(sum(df.bytes/(1024*1024))+sum(tf.bytes/(1024*1024))) TOTAL,
      2  round(sum(fs.bytes/(1024*1024))) FREE
      3* from dba_data_files df, dba_temp_files tf, dba_free_space fs
    SQL> /
         TOTAL      FREE
       6839688     56127

  • How to Validate a Portal Form field from the database

    I created a Portal Form based on a procedure, which requires three parameters. One of the parameters is Item Number. I need to check if the Item Number exists in database. I am trying to use pl/sql button event handler, where I try to use the select count(*) statement to verify. However, I don't know how to reference the form field in the where clause. Please advise. Or is it possible to achieve this by creating a javascript? If you go to 'Shared Component' provider and click on javascript, you will see some system validation scripts, which you can call in the form level validation. My doubts with javascipt is how I can talk to database in the script? Any input is appreciated.

    Hi,
    You cannot access the DB from the script. If you want to access the values of a field you should use session variables. Here is a sample to access the values of a form field.
    declare
    ticket_no varchar2(20);
    flight_no varchar2(20);
    blk varchar2(30) := 'DEFAULT';
    begin
    ticket_no := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_TICKET_NO');
    flight_no := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_FLIGHT_NO');
    end;
    Thanks,
    Sharmila

Maybe you are looking for