Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Zhuo .

Asked: May 02, 2000 - 1:21 pm UTC

Last updated: August 09, 2006 - 10:51 am UTC

Version:

Viewed 1000+ times

You Asked

Tom:
Thank you for your advice for my last question.
Today I have some question,too.
How much space has the database used?(or how much space will
the datebase be left?)




and Tom said...



run a script like this:

<quote>
------------------------------------------------------------------------------
-- free.sql
--
-- This SQL Plus script lists freespace by tablespace
------------------------------------------------------------------------------

column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a16 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"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report

select 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
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,
tablespace_name
from sys.dba_data_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by &1
/
</quote>

In sqlplus. It'll show use by tablespace & database the amount of space ALLOCATED, the amount USED and by tablespace the LARGEST CONTIGOUS FREE chunk of space (the max size of a next extent in that tablespace).




Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, August 09, 2006 - 8:12 am UTC

GRPAAA> SELECT TRIM ( office )
2 || ','
3 || TRIM ( farm )
4 || ','
5 || brn
6 || ','
7 || TRIM ( op_description )
8 || ','
9 || ALLOW
10 || ','
11 || frv
12 || ','
13 || insp
14 || ','
15 || desk
16 || ','
17 || admin_check
18 || ','
19 || claim_exists
20 || ','
21 || claim_authorised
22 || ','
23 || prev_prog
24 FROM erfc_10148
25 ORDER BY office, farm, op_description
26 /
SELECT TRIM ( office )
*
ERROR at line 1:
ORA-01658: unable to create INITIAL extent for segment in tablespace TEMPGRP


Elapsed: 00:00:00.16
GRPAAA> select count(*) from erfc_10148;

COUNT(*)
----------
27925

1 row selected.

Elapsed: 00:00:00.03
GRPAAA>


Tom,

I get the above error when I run the query with those fields, but when I do a count(*) or a "select * from erfc_10148" the results are displayed.
Why would a query use a tablespace, is it to do the trim?

If queries use tablespaces, how could we predict which tablespace will be used by a query?


More info on that table:

TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
CLUSTER_NAME IOT_NAME PCT_FREE
------------------------------ ------------------------------ ----------
PCT_USED INI_TRANS MAX_TRANS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS
---------- ---------- ---------- -------------- ----------- -----------
MAX_EXTENTS PCT_INCREASE FREELISTS FREELIST_GROUPS LOG B NUM_ROWS BLOCKS
----------- ------------ ---------- --------------- --- - ---------- ----------
EMPTY_BLOCKS AVG_SPACE CHAIN_CNT AVG_ROW_LEN AVG_SPACE_FREELIST_BLOCKS
------------ ---------- ---------- ----------- -------------------------
NUM_FREELIST_BLOCKS DEGREE INSTANCES CACHE TABLE_LO SAMPLE_SIZE LAST_ANALYZ
------------------- ---------- ---------- ----- -------- ----------- -----------
PAR IOT_TYPE T S NES BUFFER_ ROW_MOVE GLO USE DURATION SKIP_COR MON
--- ------------ - - --- ------- -------- --- --- --------------- -------- ---
CLUSTER_OWNER DEPENDEN COMPRESS
------------------------------ -------- --------
ERFC_10148 GRPAAADATA
10
40 1 255 40960 204800 1
505 1 1 1 YES N 27071 304
0 0 0 100 0
0 1 1 N ENABLED 27071 20-JUL-2006
NO N N NO DEFAULT DISABLED YES NO DISABLED YES
DISABLED DISABLED


1 row selected.

Elapsed: 00:00:00.03
GRPAAA>

Tom Kyte
August 09, 2006 - 10:51 am UTC

that is saying your temporary tablespace (which some queries will want to use and others won't) isn't quite working.


ask your dba about tempgrp - why is it "failing" - that would appear to be your temporary tablespace.

A reader, August 09, 2006 - 8:45 am UTC

Tom,

That is sorted,it appeared the temporary tablespace for the Sorting was filling up, was cleared by DBAs.

Thanks

Ravi