1

We have a UNIX box hosting an Oracle DB. We need to delete records on a daily basis from a table in this DB. We are setting up a scheduled job outside of Oracle that will run a script daily to do this.

Could you please help me create a .sh script file to do the same? I have the username/pwd for the DB.

The query is: DELETE FROM AUDIT_LOG WHERE EVENT_DATE <= SYSTIMESTAMP - 1;

2
  • Why not an Oracle Job? You could do the same thing without shell scripts. Is this an option? Commented Aug 4, 2016 at 15:23
  • Quite honestly, I prefer using Oracle Job. However, company policy for scheduled jobs is to use a separate scheduler that runs scripts and tracks them, etc. I have never written a script for Oracle related stuff and am not well-versed in UNIX scripting. Commented Aug 4, 2016 at 15:31

1 Answer 1

1

In KORN shell you can do this as below:

#!/bin/ksh

`sqlplus "<schema_name>/<password>" << EOF

set feedback off
set heading off

DELETE FROM AUDIT_LOG WHERE EVENT_DATE <= SYSTIMESTAMP - 1;

exit;
EOF`
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I will give this a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.