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

 

 

 

 

 

 

mysql删除数据库和删除数据库中的表

上一篇:[JS]以下是JS省市联动菜单代码


下一篇:SpringBoot集成BeetlSQL