I want to truncate database tables using command line.
Any directions will be highly appreciated.
I want to truncate database tables using command line.
Any directions will be highly appreciated.
#!/bin/bash
TABLES="log_customer log_visitor log_visitor_info log_url log_url_info"
for table in ${TABLES}
do
mysql dbname -e "TRUNCATE TABLE ${table};"
done
Please try with below steps to do easily..
Step1 : to create one file truncate.php in root, create array with all tables, than array load via foreach with truncateTable()
.
Step2 : run file via command line php -f truncate.php
also try with this below url :
mysql -Nse 'show tables' db_name | while read table; do mysql -e "truncate table $table" db_name;done
// db_name = database name
https://tableplus.com/blog/2018/08/mysql-how-to-truncate-all-tables.html
hope its work for you