You can use SET ECHO ON
in the beginning of your script to achieve that, however, you have to specify your script using @
instead of <
(also had to add EXIT
at the end):
test.sql
SET ECHO ON
SELECT COUNT(1) FROM dual;
SELECT COUNT(1) FROM (SELECT 1 FROM dual UNION SELECT 2 FROM dual);
EXIT
terminal
sqlplus hr/oracle@orcl @/tmp/test.sql > /tmp/test.log
test.log
SQL> SQL> SELECT COUNT(1) FROM dual; COUNT(1) ---------- 1 SQL> SQL> SELECT COUNT(1) FROM (SELECT 1 FROM dual UNION SELECT 2 FROM dual); COUNT(1) ---------- 2 SQL> SQL> EXIT