當前位置:首頁 » 操作系統 » shell循環讀取資料庫資料庫資料庫

shell循環讀取資料庫資料庫資料庫

發布時間: 2025-02-21 15:03:59

『壹』 如何使用shell腳本每天自動備份mysql資料庫

mysql備份用自帶的備份工具mysqlmp
每天自動執行用cron工具,把mysql的備份命令放在.sh文件裡面
.sh文件放在/etc/cron.daily目錄,就會每天自動執行了。

『貳』 寫個shell腳本連接oracle資料庫查詢某表數據導出為txt文件,再發送到第三

1、簡單的單列
#!/bin/sh
sqlplus 'user001/12345678'<< EOF
set define off
set hea off
spool vip1.txt
select username from ACCOUNT where LEVEL=7;
spool off
quit;
EOF
sed -i 's/[ ]*//g' ~/vip1.txt
sed -i '/^$/d' ~/vip1.txt
sed -i '1d' ~/vip1.txt
sed -i '$d' ~/vip1.txt
scp -P22 ~/vip1.txt [email protected]:/root
2、復雜的多列
#!/bin/sh
cid=$1;
today=`date +%Y-%m-%d-%H.%M`
ym=`date +%Y%m`
ymd=`date -d -1days +%Y%m%d`
last_ym=`date -d last-month +%Y%m`
next_ym=`date -d next-month +%Y%m`
file=chat_recorder_${cid}_20140707-11.xls

if [[ $1 == '' ]];then
echo "Usage: $0 company_id "
exit 0;
fi
sqlplus 'user002/12345678' << EOF
set linesize 200
set term off verify off feedback off pagesize 999
set markup html on entmap ON spool on preformat off
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
spool ${file}
select a.*,b.* from recorder_${ym} a,t_${ym} b where a.company_id='$cid' and a.create_time between TO_DATE('2014-07-07 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2014-07-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and a.chat_id=b.chat_id order by b.chat_id ;
spool off
quit;
EOF
sed -i '/select/d' $file
zip -r ${file}.zip $file
scp -P22 ${file}.zip [email protected]:/opt

『叄』 急,,,如何用shell變數接收db2資料庫查詢的結果

這樣的shell我寫過。沒什麼好辦法獲取sql查詢出來的結果。
我用個的一個比較勉強的辦法,可以自己添加一個特殊值,然後使用Grep來過濾獲取。

『肆』 Xshell怎麼連接資料庫

1、運行Xshell客戶端(事先安裝好Xshell客戶端)
2、連接遠程伺服器
3、在命令行輸入框中輸入資料庫的連介面令如:mysql
-h
192.168.10.100
-u
ju70_sql
-pwju70_sql
4、這個連介面令包含了,資料庫的host,資料庫用戶名,以及密碼,輸入後點擊回車,如下圖就表示連接成功了
5、接著輸入「use
資料庫名稱」的方式,告訴後台要使用這個資料庫,輸入後回車
6、如下圖就可以使用正常的sql語句直接在Xshell中執行就可以查詢得到想要的數據。

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:642
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:368
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:89
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:312
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:794
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:347
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:213
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:818
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:369
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:596