0

I am using Oracle11g. I have below two sql queries.

Delete from TableA;
Delete from TableB;
Delete from TableC;
Delete from TableD;
Delete from TableE;

Now how can i create a batch file to run this script By passing the credentials to connect to DB and delete using above queries?

Thanks!

1
  • I assume the above queries are just sample. Still TRUNCATE is the best option to delete the entire content of table. (Unless, a ROLLBACK is not needed) Commented Feb 4, 2014 at 11:34

1 Answer 1

1

Add the statements to a file, say "delete.sql". To execute the statements in the file, type:

sqlplus username/password@tns_name_of_your_db @delete.sql

...or simply add that into a .BAT file.

PS. Remember to add a COMMIT; statement.

PS2. Make sure the last line of "delete.sql" is empty (blank line).

Sign up to request clarification or add additional context in comments.

2 Comments

Ronnis, can this batch file be run on any machine? Or does the machine should have any software installed? Because i have to do it to delete in remote database..
You need Oracle Client to run SQL*Plus.

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.