Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

Automatate the script to delete data in table.

Kenn Chen
Advisor

Automatate the script to delete data in table.

How could I write a script to auto login to DB and delete data in certain tables.
Cyber Zen
1 REPLY
Steven Sim Kok Leong
Honored Contributor

Re: Automatate the script to delete data in table.

Hi,

To automate, you will need a shell script.

1) Execution of script as oracle account:
=====================
svrmgrl <connect internal
INSERT PL/SQL COMMANDS HERE
EOF
=====================

2) Execution of script as sqlplus user:
=====================
$ORACLE_HOME/bin/sqlplus userid/passwd <INSERT PL/SQL COMMANDS HERE
EOF
=====================
where userid is a oracle user with delete privileges. There is a security concern that the userid and password is displayed in a ps process listing.

3) To automate, use cron to call the script.
If you want to use root's crontab:
=====================
su - oracle -c delete.sh
=====================

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Email: steven@beepz.com. Homepage: https://www.beepz.com