當前位置:首頁 » 操作系統 » 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中執行就可以查詢得到想要的數據。

熱點內容
電琴腳本 發布:2025-02-22 09:32:41 瀏覽:782
磁碟陣列存儲器作用 發布:2025-02-22 09:29:51 瀏覽:680
數學之演算法 發布:2025-02-22 09:14:20 瀏覽:586
linux歷史命令查看 發布:2025-02-22 09:14:10 瀏覽:73
圖片文件夾項目 發布:2025-02-22 09:02:15 瀏覽:112
存儲報廢氣瓶 發布:2025-02-22 08:56:52 瀏覽:71
美國總統特朗普什麼時候來中國訪問的 發布:2025-02-22 08:56:51 瀏覽:905
加密機制的協議是 發布:2025-02-22 08:44:24 瀏覽:792
js函數式編程 發布:2025-02-22 08:43:39 瀏覽:584
sql伺服器登不進去怎麼辦 發布:2025-02-22 08:38:48 瀏覽:420