1. 程式人生 > 其它 >微機原理-資料傳送實驗

微機原理-資料傳送實驗

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

2.

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

drop table tablename:不但刪除表內容,而且使用droptable命令則會將整個資料庫表格的所有資訊全部刪除。

truncate tablename :刪除資料行,但保留表結構

3.

刪庫:

drop database if exists bfb_db_finance_20200831;

刪表:

drop table if existsbfb_db_cas_20200811.t_receive

drop table if existsbfb_db_cas_20200811

.t_transact

drop table if existsbfb_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