is it possible to empty all the tables in the database without dropping them with shell script?
if yes could you please show me?

thank you

Edited by nakresimin: n/a

5 Years
Discussion Span
Last Post by JeoSaurus

If you want to empty the tables of a database you are going to, at some point, use the facilities provided by the database designers to do so. This may be a command line script to drop tables or a program that uses the database API to do it programatically.
Short of deleting all of the database files on the system there isn't much of an alternative.


Hi nakresimin!

What kind of database? MySQL has a command line utility that allows you to execute database commands from a shell script. For instance, to delete all the rows in a table called bartable, in a database called dbfoo:

mysql dbfoo -e 'delete from bartable'

Of course, you'll need to have a .my.cnf file with login credentials for that database OR provide the username and password to the mysql command (mysql -uuser -ppass dbfoo ...).

That's all I've got!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.