This script is designed to assess the health of tablespaces in an Oracle database by identifying those with usage exceeding a specified target percentage. It calculates the additional space required to maintain the desired percentage of free space and provides a summary of tablespaces that need attention.
Before executing the script, ensure the following:
- Oracle Database is installed and running.
- You have the necessary privileges to run the script, including SELECT privileges on relevant database views.
- v_target_percentage: The desired percentage of free space in tablespaces (default is 95%).
- Open an Oracle SQL*Plus or SQLcl session.
- Set the server output on with the following command:
SET SERVEROUTPUT ON
- Copy and paste the script into the SQL*Plus or SQLcl session.
- Execute the script.
The script performs the following steps:
- Retrieves the name of the Oracle database instance.
- Iterates through all tablespaces in the database.
- Calculates the current size, free space, and additional space required for tablespaces exceeding the target percentage.
- Outputs a message for each identified tablespace that requires additional space.
A tablespace [INSTANCE_NAME].[TABLESPACE_NAME] needs [ADDITIONAL_SPACE] GB additional to maintain [TARGET_PERCENTAGE]% of usage.
- Adjust the v_target_percentage variable to set your desired target percentage of free space.
- Replace [INSTANCE_NAME] with the actual name of your database instance.
- It is recommended to review and adjust the script to fit your specific database environment and requirements. Disclaimer
- This script is provided as-is without any warranties. Use it at your own risk, and ensure you have adequate backups before making any changes based on the script's recommendations.