Checking Tablespace Fragmentation...

Folks,
Can someone share a high-end script for Checking Tablespace Fragmentation that shows exact numbers/values?
The one I have shows only yes or no..
Pasting my script below:
Prompt Fragmentation Level in the db
Prompt
TTitle left "*** Fragmentation Level in the db (As of:"xdate ") from mtdb" skip2
SELECT dfsc.tablespace_name tablespace_name,
DECODE (
dfsc.percent_extents_coalesced,
100,
(DECODE (
GREATEST ((SELECT COUNT (1)
FROM dba_free_space dfs
WHERE dfs.tablespace_name = dfsc.tablespace_name),
1),
1,
'No Frag',
'Fragmented'
'Possible Honey Comb Frag'
fragmentation_status
FROM dba_free_space_coalesced dfsc
ORDER BY dfsc.tablespace_name
ttitle off
results:
TABLESPACE_NAME FRAGMENTATION_STATUS
IIS_TABS1 No Frag
IIS_TABS2 No Frag
IIS_TABS3 Fragmented
IIS_TABS4 No Frag
IIS_TABS5 No Frag
regards,
Lily

Can you explain what, exactly, you mean by "tablespace fragmentation"? Assuming you are on a recent version of Oracle and using locally managed tablespaces (LMT's), fragmentation in the sense of having a chunk of space on disk that cannot be reused because it is too small is all but impossible. Technically, it is still possible in a LMT with automatic rather than uniform extent allocation, but it is exceptionally difficult in practice to come up with such a scenario.
Tablespace fragmentation was a potential problem in long-ago days when there were dictionary-managed tablespaces (DMT's) when individual objects could have different extent allocation policies and PCTINCREASE could be specified. The solution back then was to set INITIAL = NEXT = <<some reasonable constant>> and PCTINCREASE = 0 and simulate the uniform extent allocation option of LMTs.
Justin

Similar Messages

  • How to check Tablespace in DB2 with AS400

    Hi Guru,
    Can u please tell me how to check tablespace in db2 database with ecc5.

    Hi,
    very simple:
    DB2 on iSeries just has NO tablespaces ))
    => no check necessary
    Regards
    Volker Gueldenpfennig, consolut international ag
    http://www.consolut.de - http://www.4soi.de - http://www.easymarketplace.de

  • Tablespace fragmentation

    Hi All,
    How can I identify the tablespace is fragmented or not?
    If fragmented how can I resolve the issue while production database is up & running.
    Thanks in advance...

    REM     This script measures the fragmentation of free space
    REM     in all of the tablespaces in the database and scores them
    REM     according to an arbitrary index for comparison
    REM     
    REM               largest extent     100
    REM     FSFI = 100 * sqrt(------------------) * (-------------------------------)
    REM               sum of all extents sqrt(sqrt((number of extents)))
    REM     
    REM     FSFI - Free Space Fragmentation index
    REM     The largest possible FSFI (for an ideal single-file tablespace) is 100
    REM     As the number of extents increases, the FSFI rating drops slowly. As the size of
    REM     the largest extent drops, however, the FSFI rating drops rapidly.
    select          tablespace_name
    , file_id
    ,          sqrt(max(blocks)/sum(blocks)) *
              (100/sqrt(sqrt(count(blocks)))) fsfi
    from          dba_free_space
    group by     tablespace_name, file_id
    order by     1,2;
    You can move object to another tablespace and rebuild the associated indexes for tablespace fragmentation.
    Drop the old tablespace.
    Also you can go for export/import.
    Regards
    Asif Kabir

  • What is  tablespace fragmentation?

    hello all,
    please,give me more detail about tablespace fragmentation .i want to know when tablespace fragmentation occur? thanks all in advance for response.

    first thanks u and all for give me response and this wonderful link but i have a doubt which i want to ask ,when table is dropped,or truncated or raw of table is deleted then free extents is available for another request, if a request is made for an extent allocation that cannot be found in one free contiguous extent even though the total free space in the tablespace may be significantly larger than the requested size. is this a fragmentation problem?

  • How we find tablespace fragmentation and resolve this problem

    Hi,
    How we find tablespace fragmentation and resolve this in 10 G (R2) windows XP.
    Regards
    Faheem

    Hi,
    >>Are you using Dictionary Managed or Locally Managed Tablespaces...??
    In fact, there is no way to create a DMT if SYSTEM tablespace is LMT. So, what I said in my previous post "Unless the OP is using DMT ..." is impossible in Oracle 10g ...
    SQL> create tablespace tbs_test
      2      datafile '/u01/oradata/BDRPS/test01.dbf' size 5m
      3      extent management dictionary;
    create tablespace tbs_test
    ERROR at line 1:
    ORA-12913: Cannot create dictionary managed tablespace
    SQL> select extent_management from dba_tablespaces
      2  where tablespace_name='SYSTEM';
    EXTENT_MAN
    LOCALCheers
    Legatti

  • Best way to correct Tablespace fragmentation?

    Dear DBAs,
    The following query returns tablespace fragmentation:
    select
    tablespace_name,
    count(*) free_chunks,
    decode(
    round((max(bytes) / 1024000),2),
    null,0,
    round((max(bytes) / 1024000),2)) largest_chunk,
    nvl(round(sqrt(max(blocks)/sum(blocks))*(100/sqrt(sqrt(count(blocks)) )),2),
    0) fragmentation_index
    from
    sys.dba_free_space
    group by
    tablespace_name
    order by
    2 desc, 1;
    I have 3 tablespaces that are Locally Managed and suffer heavyt fragmentation. I just received the task of tuning this database and from what I could tell the fragmentation originated from a number of bad practices from past DBAs and also, some bizarre structures in certain tables.
    My question is: what would be the best way to correct tablespace fragmentation LMT? I'm thinking export - drop - import to reorganize all blocks within the tablespace?

    Alvaro wrote:
    Dear DBAs,
    The following query returns tablespace fragmentation:
    select
    tablespace_name,
    count(*) free_chunks,
    decode(
    round((max(bytes) / 1024000),2),
    null,0,
    round((max(bytes) / 1024000),2)) largest_chunk,
    nvl(round(sqrt(max(blocks)/sum(blocks))*(100/sqrt(sqrt(count(blocks)) )),2),
    0) fragmentation_index
    from
    sys.dba_free_space
    group by
    tablespace_name
    order by
    2 desc, 1;
    I have 3 tablespaces that are Locally Managed and suffer heavyt fragmentation. I just received the task of tuning this database and from what I could tell the fragmentation originated from a number of bad practices from past DBAs and also, some bizarre structures in certain tables.
    My question is: what would be the best way to correct tablespace fragmentation LMT? I'm thinking export - drop - import to reorganize all blocks within the tablespace?In addition to what everyone else notes is the unlikelihood of fragmentation, there may be implicit compaction and skew in your data distribution that could be impacted by export/import. For better or worse.
    What bad practices are you referring to? Sometimes practices are inappropriate, sometimes useless, sometimes perfectly understandable. If you don't know about the fragmentation issue, I wonder how well you judge practices. And yes, there are some really bad practices floating about.

  • What is the difference between Table & Tablespace Fragmentation

    What is the difference between Table Fragmentation & Tablespace Fragmentation.
    What causes Table Fragmentation and what cause Tablespace Fragmentation.
    How can we avoid Table Fragmentation & Tablespace Fragmentation.
    How can we fix already Fragmented Tables & Fragmented Tablespaces
    Thanks
    Naveen

    Unless you are using an exceptionally old version of Oracle or are still using dictionary managed tablespaces or are using some interesting definitions of "fragmentation", fragmentation is practically impossible in Oracle.
    Justin

  • Tablespace Fragmentation. specially in SYSTEM tablesapce.

    Hi,
    I am working on Oracle 11gR2 DB and AIX OS.
    An database is having many tablespaces which are allocated to specific schemas. These schemas are functional from a long time. Data comes and goes all the time. The size of the tablespace has gone very high(than expected). We have removed(truncated) most of the unwanted tables and data from the schema and trying to resize the datafile, but we are not able to do it.
    while checking with the below query :-
    SELECT   df.tablespace_name "Tablespace",
           df.bytes / (1024 * 1024) "Size (MB)",
           SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
           Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
           Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
      FROM dba_free_space fs,
           (SELECT tablespace_name,SUM(bytes) bytes
              FROM dba_data_files
             GROUP BY tablespace_name) df
    WHERE fs.tablespace_name (+)  = df.tablespace_name
    GROUP BY df.tablespace_name,df.bytes
    UNION ALL
    SELECT df.tablespace_name tspace,
           fs.bytes / (1024 * 1024),
           SUM(df.bytes_free) / (1024 * 1024),
           Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
           Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
      FROM dba_temp_files fs,
           (SELECT tablespace_name,bytes_free,bytes_used
              FROM v$temp_space_header
             GROUP BY tablespace_name,bytes_free,bytes_used) df
    WHERE fs.tablespace_name (+)  = df.tablespace_name
    GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
    ORDER BY 4 DESC;
    The output is :-
    tablespace name         size_MB    free_space_MB     %free  %used
      SYSTEM                34256     28941.375        84            16
       SMD                      7975     2991.1875        38            62
    .................N many other Here if i try to resize the SMD tablespace datafile to (7975-2991.1875) 4983 MB it does not allow me to do it.
    Also the SYSTEM tablespace has gone so big but used space is very less.
    I suspect that fragmentation is the problem here._
    Please guide me what could i do in these case to reduce the space taken by the datafiles.
    Thanks in advance.

    Thanks for notifying......I have a misconception about it...both the queries giving almost same result.
    but first query give you result at datafile level.
    SQL> column tablespace_name format a10
    SQL> column file_name format a32
    SQL> column file_mb format 9999990
    SQL> column hwm_mb format 9999990
    SQL> column used_mb format 9999990
    SQL> column shrnk_mb format 9999990
    SQL>
    SQL> break on report
    SQL> compute sum of file_mb on report
    SQL> compute sum of hwm_mb on report
    SQL> compute sum of used_mb on report
    SQL> compute sum of shrnk_mb on report
    SQL>
    SQL> select a.*
      2  , file_mb-hwm_mb shrnk_mb
      3  from (
      4  select /*+ rule */
      5  a.tablespace_name,
      6  a.file_name,
      7  a.bytes/1024/1024 file_mb,
      8  b.hwm*d.block_size/1024/1024 hwm_mb,
      9  b.used*d.block_size/1024/1024 used_mb
    10  from
    11  dba_data_files a,
    12  (select file_id,max(block_id+blocks-1) hwm,sum(blocks) used
    13  from dba_extents
    14  group by file_id) b,
    15  dba_tablespaces d
    16  where a.file_id = b.file_id
    17  and a.tablespace_name = d.tablespace_name
    18  ) a
    19  order by a.tablespace_name,a.file_name;
    TABLESPACE FILE_NAME                         FILE_MB   HWM_MB  USED_MB SHRNK_MB
    SYSAUX     C:\ORACLEXE\APP\ORACLE\ORADATA\X      710      673      672       37
               E\UNDOTBS1.DBF
    SYSTEM     C:\ORACLEXE\APP\ORACLE\ORADATA\X      360      353      352        7
               E\SYSTEM.DBF
    UNDOTBS1   C:\ORACLEXE\APP\ORACLE\ORADATA\X      260      258      257        2
               E\SYSAUX.DBF
    USERS      C:\ORACLEXE\APP\ORACLE\ORADATA\X     6340     6017     6016      323
               E\USERS.DBF
    TABLESPACE FILE_NAME                         FILE_MB   HWM_MB  USED_MB SHRNK_MB
    sum                                             7670     7301     7296      369
    SQL> SELECT /* + RULE */  df.tablespace_name "Tablespace",
      2         df.bytes / (1024 * 1024) "Size (MB)",
      3         SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
      4         Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
      5         Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
      6    FROM dba_free_space fs,
      7         (SELECT tablespace_name,SUM(bytes) bytes
      8            FROM dba_data_files
      9           GROUP BY tablespace_name) df
    10   WHERE fs.tablespace_name (+)  = df.tablespace_name
    11   GROUP BY df.tablespace_name,df.bytes
    12  UNION ALL
    13  SELECT /* + RULE */ df.tablespace_name tspace,
    14         fs.bytes / (1024 * 1024),
    15         SUM(df.bytes_free) / (1024 * 1024),
    16         Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
    17         Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
    18    FROM dba_temp_files fs,
    19         (SELECT tablespace_name,bytes_free,bytes_used
    20            FROM v$temp_space_header
    21           GROUP BY tablespace_name,bytes_free,bytes_used) df
    22   WHERE fs.tablespace_name (+)  = df.tablespace_name
    23   GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
    24   ORDER BY 4 DESC;
    Tablespace                      Size (MB)  Free (MB)     % Free     % Used
    TEMP                                   20         17         85         15
    USERS                                6340   323.3125          5         95
    SYSAUX                                710      37.25          5         95
    SYSTEM                                360     7.3125          2         98
    UNDOTBS1                              260     1.8125          1         99
    SQL>

  • Removing Tablespace fragmentation in 10g

    i have a problem with a tablespace space that is highly fragmented . It's locally managed with PCT_INCREASE set to 0. How can i reduce the fragmentation in this tablepsace
    Free/Used Space Report :
    Tablespace                        Used MB    Free MB   Total MB  Pct. Free
    FRP_I01                            158556      44625     203181         22
    select PCT_INCREASE,EXTENT_MANAGEMENT,SEGMENT_SPACE_MANAGEMENT from dba_tablespaces where TABLESPACE_NAME='FRP_I01';
    PCT_INCREASE EXTENT_MAN SEGMEN
               0 LOCAL      AUTO
    fragmentation report :
    select
      2  tablespace_name,
      3  count(*) free_chunks,
    decode(
      4    5  round((max(bytes) / 1024000),2),
      6  null,0,
      7  round((max(bytes) / 1024000),2)) largest_chunk,
      8  nvl(round(sqrt(max(blocks)/sum(blocks))*(100/sqrt(sqrt(count(blocks)) )),2),
      9  0) fragmentation_index
    10  from
    11  sys.dba_free_space
    12  group by tablespace_name
    13  having tablespace_name='FRP_I01'
    14  order by
    15  2 desc, 1;
    TABLESPACE_NAME                FREE_CHUNKS LARGEST_CHUNK FRAGMENTATION_INDEX
    FRP_I01                                201         11904               13.56
    SELECT   dfsc.tablespace_name tablespace_name,
      2           DECODE (
      3              dfsc.percent_extents_coalesced,
                100,
      4    5              (DECODE (
      6                  GREATEST ((SELECT COUNT (1)
      7                               FROM dba_free_space dfs
      8                              WHERE dfs.tablespace_name = dfsc.tablespace_name), 1),
      9                  1,
    10                  'No Frag',
    11                  'Bubble Frag'
    12               )
    13              ),
    14              'Possible Honey Comb Frag'
    15           )
    16                 fragmentation_status
    17      FROM dba_free_space_coalesced dfsc
    18  where dfsc.tablespace_name='FRP_I01'
    19  ORDER BY dfsc.tablespace_name;
    TABLESPACE_NAME                FRAGMENTATION_STATUS
    FRP_I01                        Bubble Frag

    yes, i know that. But as per my script this particular tablespace is fragmented and i want to know if some1 can help me out how to defragment it ?
    A 100% score indicates no fragmentation at all. Lesser scores verify the presence of fragmentation.The free chunks count column will tell you how many segments of free space are scattered throughout the tablespace.
    thanks in advance

  • Tablespace fragmentation problem

    All,
    I am working in Oracle 9i. Developers are facing some problem. Oracle is throwing ORA-1654 error. There is enough space in the tablespaces. To me it seems to be fragmentation problem. I found one query on some site and executed in my environment.
    SQL> select substr(ts.name, 1,10) TableSpace,to_char(f.file#,990) "file #",tf.blocks blocks,sum(f.length) free,to_char(count(*),9990) frags,max(f.length) bigst, to_char(min(f.length),999990) smllst,round(avg(f.length)) avg,to_char(sum(decode(sign(f.length-5), -1, f.length,0)),99990) dead from sys.fet$ f, sys.file$ tf, sys.ts$ ts where ts.ts# = f.ts# and ts.ts# = tf.ts# group by ts.name, f.file#, tf.blocks;
    TABLESPACE file BLOCKS FREE FRAGS BIGST SMLLST AVG DEAD
    GAP_ARC 7 15360 8239 108 6099 20 76 0
    GAP_BILD 8 256000 223804 3655 77909 5 61 0
    GAP_DATA 9 230400 48267 211 3937 5 229 0
    GAP_GEN 10 192000 86156 902 52178 1 96 3
    GAP_IMP 11 38400 37669 14 37399 10 2691 0
    GAP_INDEX 12 230400 96408 3557 506 1 27 5335
    GAP_INDEX 12 409600 96408 3557 506 1 27 5335
    GAP_INDEX 13 230400 56120 1611 495 2 35 2627
    GAP_INDEX 13 409600 56120 1611 495 2 35 2627
    GAP_ZNZL 14 1920 1919 50 515 10 38 0
    RBS 3 51200 30479 871 35 29 35 0
    RBS_BIG 4 76800 63929 157 43649 130 407 0
    SYSTEM 1 25600 25952 2 12976 12976 12976 0
    SYSTEM 2 25600 22728 20 11321 2 1136 12
    TEMP 5 64000 58279 252 25649 130 231 0
    TOOLS 6 6400 6384 1 6384 6384 6384 0
    16 Zeilen ausgewählt.
    From the output it seems GAP_INDEX has some fragmentation problem. Can somebody suggest, what the output means particularly the "DEAD" one.
    And also, how to do the fragmentation ??
    Thanks for help.
    Regards,
    Rajeev

    I haven't taken the time to study the query in depth but I think 'dead' is an attempt to identify free exents that are too small to be used.
    The original post leaves out some very important information such as the type of tablespace space allocation in use: dictionary vs local with auto-allocate or uniform extents.
    As one poster noted if you use locally managed tablespaces wtih uniform extents then free space fragmentation by definition cannot exist.
    With auto-allocate and dictionary mangement it can. Auto-allocate generally extents the time till a tablespace's free space becomes fragemented such that the space is not usuable and contains logic to reclaim via reuse but with the right combination of very small and very large objects the problem can still exist.
    Dictionary management is almost bound to lead to free space fragmentation conditions for an active system though the adoption of a proper extent sizing policy can help: initial = next with pctincrease = 0 for all objects in a tablespace and the extent sizes for the larger objects being an even multiple of the small object extent size.
    For auto-allocate and especially dictionary management when free space gets low the options are re-create the objects to consolidate all free space into a few large contiguous chunks or add another file. Sometimes you can relocate an object whose extents can then be reused by other objects. With uniform extents moving an object to another tablespace always creates fully reusable free space. Since objects should be where you want them the only real option then is to add free space is to add a file. Managing free space in a uniform extent environment then is genarally very straight forward.
    HTH -- Mark D Powell --

  • Check TableSpace availability

    Is there any query which can check how much data a tablespace can store, I mean, how many space is used and how many space is free?
    Thank you.

    Try this one or modify as per ur requirement.
    SELECT NVL (b.tablespace_name, NVL (a.tablespace_name, 'UNKOWN')) NAME,2 mbytes_alloc mbytes, mbytes_alloc - NVL (mbytes_free, 0) used,
    3 NVL (mbytes_free, 0) free,
    4 ((mbytes_alloc - NVL (mbytes_free, 0)) / mbytes_alloc)
    5 * 100 pct_used,
    6 100
    7 - (((mbytes_alloc - NVL (mbytes_free, 0)) / mbytes_alloc) * 100)
    8 pct_free
    9 FROM (SELECT SUM (BYTES) / 1024 / 1024 mbytes_free, tablespace_name
    10 FROM SYS.dba_free_space
    11 GROUP BY tablespace_name) a,
    12 (SELECT SUM (BYTES) / 1024 / 1024 mbytes_alloc, tablespace_name
    13 FROM SYS.dba_data_files
    14 GROUP BY tablespace_name) b
    15 WHERE a.tablespace_name(+) = b.tablespace_name
    16 UNION ALL
    17 SELECT f.tablespace_name,
    18 SUM (ROUND ((f.bytes_free + f.bytes_used) / 1024 / 1024, 2)
    19 ) "total MB",
    20 SUM (ROUND (NVL (p.bytes_used, 0) / 1024 / 1024, 2)) "Used MB",
    21 SUM (ROUND ( ((f.bytes_free + f.bytes_used) - NVL (p.bytes_used, 0)
    22 )
    23 / 1024
    24 / 1024,
    25 2
    26 )
    27 ) "Free MB",
    28 (SUM (ROUND (NVL (p.bytes_used, 0) / 1024 / 1024, 2)) * 100)
    29 / (SUM (ROUND ((f.bytes_free + f.bytes_used) / 1024 / 1024, 2))),
    30 100
    31 - (SUM (ROUND (NVL (p.bytes_used, 0) / 1024 / 1024, 2)) * 100)
    32 / (SUM (ROUND ((f.bytes_free + f.bytes_used) / 1024 / 1024, 2)))
    33 FROM SYS.v_$temp_space_header f,
    34 dba_temp_files d,
    35 SYS.v_$temp_extent_pool p
    36 WHERE f.tablespace_name(+) = d.tablespace_name AND f.file_id(+) = d.file_id
    37 AND p.file_id(+) = d.file_id
    38 GROUP BY f.tablespace_name
    39 ORDER BY 4;

  • Check tablespace

    Hi brother,
    i would like to check the sinagle tablespace on Oracle 10g DB, where can I found the script?
    Thanks

    I've used script from asktom, that's great....
    set linesize 130
    set pages 1000
    -- Thank AskTom
    -- This SQL Plus script lists freespace by tablespace
    column dummy noprint
    column pct_used format 999.9 heading "%|Used"
    column name format a19 heading "Tablespace Name"
    column Kbytes format 999,999,999 heading "KBytes"
    column used format 999,999,999 heading "Used"
    column free format 999,999,999 heading "Free"
    column largest format 999,999,999 heading "Largest"
    column max_size format 999,999,999 heading "MaxPoss|Kbytes"
    column pct_max_used format 999.9 heading "%|Max|Used"
    break on report
    compute sum of kbytes on report
    compute sum of free on report
    compute sum of used on report
    select (select decode(extent_management,'LOCAL','*',' ') ||
    decode(segment_space_management,'AUTO','a ','m ')
    from dba_tablespaces where tablespace_name = b.tablespace_name) ||
    nvl(b.tablespace_name,
    nvl(a.tablespace_name,'UNKOWN')) name,
    kbytes_alloc kbytes,
    kbytes_alloc-nvl(kbytes_free,0) used,
    nvl(kbytes_free,0) free,
    ((kbytes_alloc-nvl(kbytes_free,0))/
    kbytes_alloc)*100 pct_used,
    nvl(largest,0) largest,
    nvl(kbytes_max,kbytes_alloc) Max_Size,
    decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
    from ( select sum(bytes)/1024 Kbytes_free,
    max(bytes)/1024 largest,
    tablespace_name
    from sys.dba_free_space
    group by tablespace_name ) a,
    ( select sum(bytes)/1024 Kbytes_alloc,
    sum(maxbytes)/1024 Kbytes_max,
    tablespace_name
    from sys.dba_data_files
    group by tablespace_name
    union all
    select sum(bytes)/1024 Kbytes_alloc,
    sum(maxbytes)/1024 Kbytes_max,
    sum(maxbytes)/1024 Kbytes_max,
    tablespace_name
    from sys.dba_temp_files
    group by tablespace_name )b
    where a.tablespace_name ( + ) = b.tablespace_name;
    Enjoy!

  • Check tablespace capacity and quota left?

    How do I check a specific tablespace capacity and quota left?
    Thanks!

    I guess you do not have 'Select any table' privilege,
    Be granted 'Select any table' by SYS or any DBA user. then try.
    SELECT Total.name "Tablespace Name",
            nvl(Free_space, 0) Free_space,
            nvl(total_space-Free_space, 0) Used_space,
            total_space
    FROM
       (select tablespace_name, sum(bytes/1024/1024) Free_Space
          from sys.dba_free_space
         group by tablespace_name
       ) Free,
       (select b.name,  sum(bytes/1024/1024) TOTAL_SPACE
          from sys.v_$datafile a, sys.v_$tablespace B
         where a.ts# = b.ts#
         group by b.name
       ) Total
    WHERE Free.Tablespace_name(+) = Total.name
    and Free.Tablespace_name='USERS'
    ORDER BY Total.name
    Tablespace Name                FREE_SPACE USED_SPACE TOTAL_SPACE
    USERS                             38.1875    11.8125          50

  • Query to check tablespace size and freespace

    hi experts
    i am using oracle 9i .
    want ot check freespace and size of tablespace could u plz tell me the query
    thanks
    varun

    add following for temp files -
    select sum(bytes)/1024 kbytes_alloc, tablespace_name
    from sys.dba_temp_files
    group by tablespace_name
    the new query will be
    select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
    from
    (select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_space
    from dba_free_space group by tablespace_name) a,
    (select tablespace_name, sum(bytes)/1024/1024 as tbs_size
    from dba_data_files group by tablespace_name
    UNION
    select tablespace_name, sum(bytes)/1024/1024 tbs_size
    from dba_temp_files
    group by tablespace_name ) b
    where a.tablespace_name(+)=b.tablespace_name;
    cheers

  • Checking tablespace used space, free space in ASM

    Hi,
    I want to find the tablespace used space, free space, total space in an ASM (Automatic Storage Management) environment. What is the query for that ?
    Thanks

    want to find the tablespace used space, free spaceUse same script that u are used in non-asm environment.
    dba_data_files
    dba_free_space
    total space in an ASM (Automatic Storage Management) environment.select name, type, total_mb, free_mb, required_mirror_free_mb,
    usable_file_mb from v$asm_diskgroup;
    Thanks
    Kuljeet

Maybe you are looking for

  • Windows XP laptop can't connect to Airport Extreme used to extend network.

    Have a time capsule for main wireless. PC works fine connecting to it. Have added Airport Extreme to extend network. The mac sees it fine and the PC can connect to it via airport utility but won't connect as wireless and the internet. Running WPA2. H

  • Applicatio​n builder error creating

    After install Labview 9.0f2, no longer is possible to build application Solved! Go to Solution.

  • Constraints and Browser Scrollbars

    I am trying to create an application that is targeted for a resolution of 1024x768. For those will larger resolutions I would like the application to scale to the available area. For those with smaller resolutions I would like the browsers scroll bar

  • Temporary Tables in Stored Procedure

    Hi, I am writing a stored procedure that will get data from different sources and generates a spreadsheet finally. Initial select gets the basic data and following selects merges data. For this I have created a table in the database, I am populating

  • Implementing two 1:M relationships

    Hello, I have a Oppty Fact. As an Extension to it I have resource fact and case fact. Oppty Fact : Resource fact = 1: M opty fact : case fact = 1:M. We need a report with oppty name (from oppty fact), Amount (from oppty fact) , REsource name (from re