How can we query the size of a data table in PL/SQL?

You can query the size of a data table in PL/SQL by executing the following SQL statement:

SELECT 
    segment_name AS table_name,
    SUM(bytes) / 1024 / 1024 AS size_mb
FROM 
    user_segments
WHERE 
    segment_type = 'TABLE'
GROUP BY 
    segment_name;

This SQL statement will query the size of all tables in the user_segments view (in MB) and group them by table name. You can save it as a stored procedure or execute it in a PL/SQL block.

bannerAds