如果是通過shell腳本運(yùn)行Oracle的sql語句,可以這樣寫shell腳本:
10年的鄲城網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整鄲城建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“鄲城網(wǎng)站設(shè)計(jì)”,“鄲城網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
echo “Oracle SQL Example"
sqlplus / as sysdba EOF
select * from scott.emp;
EOF
也就是把sql語句寫到shell腳本的EOF之間。
1、簡(jiǎn)單的單列
#!/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 root@172.16.1.2:/root
2、復(fù)雜的多列
#!/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 root@172.16.1.5:/opt
-- Create the user
create user SH
default tablespace USERS
temporary tablespace TEMP
profile DEFAULT
password expire
account lock;
-- Grant/Revoke object privileges
grant read on directory DATA_FILE_DIR to SH;
grant execute on DBMS_STATS to SH;
grant read, write on directory LOG_FILE_DIR to SH;
-- Grant/Revoke role privileges
grant cwm_user to SH;
grant resource to SH;
grant select_catalog_role to SH;
-- Grant/Revoke system privileges
grant alter session to SH;
grant create cluster to SH;
grant create database link to SH;
grant create dimension to SH;
grant create materialized view to SH;
grant create sequence to SH;
grant create session to SH;
grant create synonym to SH;
grant create table to SH;
grant create view to SH;
grant query rewrite to SH;
grant unlimited tablespace to SH;
這個(gè)使用sys用戶進(jìn)入查看用戶的信息,你想知道他是干嘛的,看這個(gè)用戶賦予了那些權(quán)限,想用這個(gè)用戶,需要先給這個(gè)用戶解鎖,然后修改密碼就可以了
這個(gè)問題你可能通過查詢oracle的系統(tǒng)表,例如all_all_tables,用這些對(duì)象的列表生成一批數(shù)據(jù)庫刪除對(duì)象的語句,然后將這些語句存到文件,用sqlplus的文件參數(shù)執(zhí)行這一批語句。
新聞名稱:怎么通過sh訪問oracle的簡(jiǎn)單介紹
標(biāo)題來源:http://sd-ha.com/article14/hsecde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、網(wǎng)站收錄、商城網(wǎng)站、品牌網(wǎng)站建設(shè)、建站公司、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)