Oracle Table and Database Size

To obtain the table size on an Oracle database, the following script can be used:


SELECT lower(table_name) AS tableName
    ,tablespaceName
    ,totalRows
    ,blocks*8/1024 AS Mbytes
FROM all_tables
WHERE owner = USER
ORDER BY 1,2;

Performing the sum of the sizes of all tables allow us to get an estimate of the database size:


SELECT sum(blocks*8/1024) AS TotalMbytes
FROM all_tables
WHERE owner = USER;

The previous script may not be accurate because it actually gets the sum of the size of the tables, which can be simply viewed as the data size, since a database is more than just data on tables.