1.11M Members

how to empty database tables

 
0
 

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

 
0
 

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.

 
0
 

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!

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article