How can you query the size of data files in PLSQL?

In PL/SQL, you can use the following query to obtain the size of a data file:

SELECT file_name, bytes / 1024 / 1024 AS size_mb
FROM dba_data_files;

The query above retrieves the names and sizes of data files from the dba_data_files view. The size of the files is shown in bytes, which can be converted to MB by dividing by 1024 twice.

If you only want to query the size of data files for a specific tablespace, you can add a WHERE clause to filter the results. For example, the following query will return the size of data files in tablespace USERS:

SELECT file_name, bytes / 1024 / 1024 AS size_mb
FROM dba_data_files
WHERE tablespace_name = 'USERS';
bannerAds