There are various method of estimating and projecting the size of a table . The best way to estimate database size is to load some sample data into our tables and then calculate statistics on those tables. Query DBA_TABLES for the AVG_ROW_LEN to get an idea of the average number of bytes for each row. We can use Tom Kyte’s (asktom.com) show_space code to help us with the #of blocks evaluation or just use a plain simple technique shown below. Many people just use the average rowlength (avg_row_len column) in order to as certain the size after doing a CTAS (Create Table AS)…however, that is not accurate as we will show below:
All the Views expressed here are my own and do not reflect opinions or views of the anyone else.All the views are tested on my testing environment and kindly test the post before applying anything on production.You can reach to me at neeraj.vishen@gmail.com .
Thursday, April 7, 2011
Wednesday, April 6, 2011
How to find startup & shutdown time of Oracle Database
Sometimes, we have to determine the startup and shutdown history of a database . There is no any data-dictionary tables which contains the history of startup and shutdown time . Sometimes a system administrator reboot server in such cases we can determines the startup and shutdown time by checking the alert logfile. Since alert logfile keeps on increasing and we manages the alert logfile either by truncate or deleting its contains .
Instead of depending on alert logfile , we can create table which contains the history of startup and shutdown by using the triggers . Here we will create two triggers i.e, first trigger will fired once the database is startup and second trigger is fired when database is shutdown . Let's have a look .
1.) Create a table to store history
SQL> create table db_history ( time date , event varchar2(12)) ;
Table created.
2.) Create trigger for catching startup time
SQL>create or replace trigger dbhist_start_trigr
after startup on database
begin
insert into db_history values (sysdate , 'StartUp' ) ;
end ;
/
Trigger created.
3.) Create Trigger to catch shutdown time
SQL> create or replace trigger dbhist_shut_trigr
before shutdown on database
begin
insert into db_history values (sysdate, 'ShutDown' ) ;
end;
/
Trigger created.
Enjoy :-)
Estimate Oracle Database Size
Oracle database is consists of datafiles, controlfiles and redolog files . Therefore , the size of oracle database can be calculated by adding above files. The below script will estimate the oracle database size .
Total_size in GB
----------------
1.9475708
Enjoy :-)
SQL> select a.datafile_size + b.temp_size + c.redo_size + d.controlfile_size "Total_size in GB"
from ( select sum(bytes)/1024/1024/1024 as datafile_size
from dba_data_files) a,
( select nvl(sum(bytes),0)/1024/1024/1024 as temp_size
from dba_temp_files ) b,
( select sum(bytes)/1024/1024/1024 as redo_size
from sys.v_$log ) c,
( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 as controlfile_size
from v$controlfile) d ;
output :
output :
Total_size in GB
----------------
1.9475708
Enjoy :-)
Subscribe to:
Comments (Atom)