Hi,
In general we DBAs Create datafiles ,drop datafiles too. But we may want to know when I created the datafile and when I dropped it and what was its size . But once you drop you will not have those information in any of the system tables such as DBA_DATA_FILES (or) V$datafile etc.
The alert.log will have this but it is always good to know the following
Will Oracle Keep track of the history of datafiles created and dropped?
If Yes , then where can I find?
To answer this , I will explain how oracle works on this internally.
Let us assume we create a new database with 100 datafiles comprising of various tablespaces.
Oracle allocates a file# to each of the files using its internal sequence created.
So for 100 datafiles we will be having file# starting from 1 to 100. Now let us assume I create a new tablespace with 1 datafile then my counter becomes 101.
Now if I drop a tablespace having 5 datafiles then my counter still is 101 but I have 5 slots empty for file#. Assume 91,92,93,94 and 95. Now if I again create 2 tablespaces one with 2 datafiles and other with 3 datafiles then , Oracle will reuse this slot of 91 to 95.
All these changes are dyanmically captured in a X$ table called X$KCCFE.
Check the below query
select a.fenum,
a.fecrc_tim as created_time,
a.festt as dropped_time,
(a.fecsz*b.value)/1024/1024 as file_size
from sys.X$kccfe a,V$parameter b
where name='db_block_size'
and a.feflg!=0
and a.fenum not in (select file# from V$datafile);
This query will only have dynamic data.
regards,
Vijay Kaushik
Tuesday, June 9, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment