SP2-0310
Saw error SP2-0310 when we tried to execute a SQL script in SQL*Plus.
SQL> @awrrpt.sql
SP2-0310: unable to open file "awrrpt.sql"
SP2-0310 means that sqlplus cannot find any matched SQL file you specified, so it's unable to open and execute the file.
In this case, we didn't prefix any path to the file. Without any relative or absolute path, sqlplus looks for the file in your present working directory (PWD).
Let's see what present working directory (PWD) is.
SQL> !pwd
/u01/app/oracle/product/19.0.0/db_1
The problem is that the PWD does not have the SQL file.
Solutions
To overcome such problem, we have several options.
Change PWD
We can change PWD to the path where the SQL file is at.
[oracle@test db_1]$ cd rdbms/admin
[oracle@test admin]$
Then do it again in sqlplus.
SQL> @awrrpt.sql
Relative Path
Specifying a relative path can also make sqlplus know where the SQL file is.
Child Directory
SQL> @rdbms/admin/awrrpt.sql
Neighbor Directory
SQL> @../../19.0.0/db_1/rdbms/admin/awrrpt.sql
Which means, double dots can be used here.
Absolute Path
Specifying the absolute path is also safer.
SQL> @/u01/app/oracle/product/19.0.0/db_1/rdbms/admin/awrrpt.sql
If the path of ORACLE_HOME is a part of it, you may use a question mark, an Oracle-used symbol to make the command shorter.
SQL> @?/rdbms/admin/awrrpt.sql
Done!