Thursday, January 8, 2009

Why there is a diff btwen DBA_SEGMENTS & DATAPUMP of particular schema size

Why there is a difference between DBA_SEGMENTS & DataPUMP of size of particular schema
======================================================================================

1. SELECT SUM(bytes)/1024/1024/1024 AS size_gig FROM DBA_SEGMENTS WHERE OWNER= 'XXX';

2. $ expdp estimate_only=y schemas=xxx

In Common, data pump export would show less value than the size computed from dba_segments/extents


ESTIMATE_ONLY - Use this parameter to estimate the required export file size without starting an actual export job.
ESTIMATE - The ESTIMATE parameter will tell you how much space your new export job is going to consume.
Estimate_only shows the export dump file size not a schema size.

Also, DBA_SEGMENTS contains INDEX segments too,

So, The following query may give you close result

select sum(bytes)/1024/1024/1024 as size_gig, segment_type
from dba_segments
where owner='ENDUR01'
group by segment_type;

Wednesday, January 7, 2009

How to get the Schema/User size

In SQLPLUS run any of the following scripts to find the total size occupied by a particular schema.


1.

SQL> SELECT sum(bytes)/1024/1024 FROM user_segments;


The output above query would be similar as follows:


SUM(BYTES)/1024/1024
——————–
2552.75


-- OR --

2.

SQL> SELECT tablespace_name, Sum(bytes)/1024/1024 AS total_size_mb
FROM dba_segments
WHERE owner = Upper(&User_Name)
GROUP BY owner, rollup(tablespace_name)


-- OR --

3. To be more precise on particular table which excluding index,lob segments etc

SQL> SELECT sum(bytes)/1024/1024/1024 as size_gig, segment_type
FROM dba_segments
WHERE owner='XXX'
GROUP BY segment_type;