mysql刪除數據庫和刪除數據庫中的表


1. select sleep(2);執行睡眠2秒

2. 

delete from tablename:清空一個表內容,但不清空表結構,該表格仍然存在,而且表格中列的信息不會改變

drop table tablename:不但刪除表內容,而且使用drop table命令則會將整個數據庫表格的所有信息全部刪除。

truncate tablename :刪除數據行,但保留表結構

3.

刪庫:

drop database if exists bfb_db_finance_20200831;

刪表:

drop table if exists bfb_db_cas_20200811.t_receive

drop table if exists bfb_db_cas_20200811.t_transact

drop table if exists bfb_db_cas_20200811.t_transact_refund_log

DB_CONNECTOR="-h 10.10.10.10 -P 3306 -u user -p123123"                                                      
DB_CMD="mysql $DB_CONNECTOR"
#刪除此時間之前的數據庫或表 begintime="20200901" n=0; while true; do
#日期后退 now=`date +"%Y%m%d" -d "+${n} days"` if [ ${now} -lt $begintime ]; then $DB_CMD -e "drop database if exists bfb_db_finance_${now}" >> log.log echo "bfb_db_finance_${now} has been deleted" >>log.log sleep 3 $DB_CMD -e "drop table if exists bfb_db_cas_${now}.t_transact_refund_log" echo "bfb_db_cas_${now}.t_transact_refund_log has been deleted" >> log.log sleep 3 $DB_CMD -e "drop table if exists bfb_db_cas_${now}.t_receive" echo "bfb_db_cas_${now}.t_receive has been deleted" >> log.log sleep 3 $DB_CMD -e "drop table if exists bfb_db_cas_${now}.t_transact" echo "bfb_db_cas_${now}.t_transact has been deleted" >> log.log sleep 3 fi let n-- sleep 0.1 done

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM