Monday, August 16, 2010

Calculating size of a table in Oracle

Before calculating the size of a table, one should understand how a table is stored.

A table is physically stored in a datafile on disk. Oracle reserves a defined space before writing the data. The data file is organized in to chunks called segments, which further contains chunks named extents and each extent is organized in to most atomic units called the blocks. The size of the block is determined by the Oracle init parameter named "db_block_size".


The data dictionary stores the details of filled and free blocks or extents. (You should do a step called "analyze" to gather the table statistics)
something like analyze table MYTAB compute statistics;
This might take long time depending on your tablesize.

And now you are ready to query the data dictionary tables to find the size occupied by the table.

select sum(blocks) from user_extents
where segment_name = 'TABLE_NAME'
and segment_type = 'TABLE';

or 

select blocks,EMPTY_BLOCKS,avg_space,
avg_row_len,NUM_FREELIST_BLOCKS  from user_tables
where table_name='TABLE_NAME';


My personal choice is the first query.

Final steps ...
1. Know the block size by running "show parameter db_block_size" in sqlplus.
2. Multiply the block size by sum(blocks), and you get the table size.

Wednesday, July 21, 2010

SQL Server 2008 for the Oracle DBA

For those who have lived long enough working Oracle, and if you wish to learn SQL server 2008 by mapping feature set to Oracle database, then this is the video for you.

http://technet.microsoft.com/en-us/sqlserver/dd548020.aspx

Quick Summary from the link:
This 15 modules, level 300 course provides students with the knowledge and skills to capitalize on their skills and experience as an Oracle DBA to manage a Microsoft SQL Server 2008 system. This workshop provides a quick start for the Oracle DBA to map, compare, and contrast the realm of Oracle database management to SQL Server database management.

Monday, July 19, 2010

Feynman Algorithm - Interesting to read

Source: http://www.c2.com/cgi/wiki?FeynmanAlgorithm

The Feynman Algorithm:
  1. Write down the problem.
  2. Think real hard.
  3. Write down the solution.
The Feynman algorithm was facetiously suggested by Murray Gell-Mann, a colleague of Feynman, in a New York Times interview.

Tuesday, June 22, 2010

Working with DML in parallel (Oracle 11gR2 feature in PLSQL)

http://www.oracle.com/technology/oramag/oracle/10-may/o30plsql.html

This link has comprehensive coverage about this new feature introduced in Oracle 11g R2.

New learning in PLSQL - NO_DATA_NEEDED exception

I have many times come across the NO_DATA_FOUND exception. Thanks for Asktom site for pointing me to NO_DATA_NEEDED exception.  There are always enough things to learn as long as mind is keen to observe around.

Thursday, June 3, 2010

H2 Database Engine

After a few days of working with databases, I came across an in-memory DB named H2 database.
CRUISE is an wonderful continuous integration build enabler and this product uses H2 database. Hope to dig this tool a bit.

More details about this can be found at http://www.h2database.com/html/main.html