这篇文章给大家分享的是有关如何获取完整的sqltext脚本的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
#!/bin/bash
# by ray
# 2017-08-31
#v0.1
##get sqltext from dbs_hist_sqltext,sqltext will be save current directory and file name will be sql_id.txt
FromHist(){
sqlplus -s /nolog
conn / as sysdba
set linesize 300
set serveroutput on
set feedback off
spool ./$1.txt
declare
l_buffer varchar2(3000);
l_amount binary_integer :=3000;
l_pos int :=1;
l_clob_length int;
sqlid varchar2(100) := ‘$1’;
begin
select DBMS_LOB.getlength(sql_text) into l_clob_length from dba_hist_sqltext where sql_id=sqlid;
while l_pos
select DBMS_LOB.SUBSTR(sql_text,l_amount,l_pos) into l_buffer from dba_hist_sqltext where sql_id=sqlid;
dbms_output.put(l_buffer);
l_pos:=l_pos+l_amount;
end loop;
dbms_output.put_line(‘ ‘);
end;
/
spool off
exit
RAY
}
##get sqltext from V$sqlarea,sqltext will be save current directory and file name will be sql_id.txt
FromMomery(){
sqlplus -s /nolog
conn / as sysdba
set linesize 300
set serveroutput on
set feedback off
spool ./$1.txt
declare
l_buffer varchar2(3000);
l_amount binary_integer :=3000;
l_pos int :=1;
l_clob_length int;
sqlid varchar2(100) := ‘$1’;
begin
select DBMS_LOB.getlength(sql_fulltext) into l_clob_length from v$sqlarea where sql_id=sqlid;
while l_pos
select DBMS_LOB.SUBSTR(sql_fulltext,l_amount,l_pos) into l_buffer from v$sqlarea where sql_id=sqlid;
dbms_output.put(l_buffer);
l_pos:=l_pos+l_amount;
end loop;
dbms_output.put_line(‘ ‘);
end;
/
spool off
exit
RAY
}
func_help(){
echo “–from specifying how to get sqltext,memery or hist can be used.default momery!!”
echo “–sqlid specify a sql_id”
echo “for example:”
echo “get_fulltext.sh –from=momery –sqlid=*********”
}
#get parameter
argvs=($@)
for i in ${argvs[@]}
do
case `echo $i | awk -F ‘=’ ‘{print $1}’ | awk -F ‘–‘ ‘{print $2}’| tr [a-z] [A-Z]` in
FROM)
fm=`echo $i | awk -F ‘=’ ‘{print $2}’ | tr [a-z] [A-Z]`
;;
SQLID)
sqlid=`echo $i | awk -F ‘=’ ‘{print $2}’ `
;;
HELP)
func_help
exit 1
esac
done
if [ ! ${fm} ]; then
fm=’MOMERY’
fi
if [ ! ${sqlid} ]; then
echo “The sql_id must be specified!!”
exit 1
fi
##exec script
if [ ${fm} == “HIST” ];then
FromHist “${sqlid}”
elif [ ${fm} == “MOMERY” ];then
FromMomery “${sqlid}”
else
echo “then type of parameter only are HIST or MOMERY!!”
fi
感谢各位的阅读!关于“如何获取完整的sqltext脚本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
select DBMS_LOB.SUBSTR(sql_text,l_amount,l_pos) into l_buffer from dba_hist_sqltext where sql_id=sqlid;
dbms_output.put(l_buffer);
l_pos:=l_pos+l_amount;
end loop;
dbms_output.put_line(‘ ‘);
end;
/
spool off
exit
RAY
}
##get sqltext from V$sqlarea,sqltext will be save current directory a免费主机域名nd file name will be sql_id.txt
FromMomery(){
sqlplus -s /nolog
conn / as sysdba
set linesize 300
set serveroutput on
set feedback off
spool ./$1.txt
declare
l_buffer varchar2(3000);
l_amount binary_integer :=3000;
l_pos int :=1;
l_clob_length int;
sqlid varchar2(100) := ‘$1’;
begin
select DBMS_LOB.getlength(sql_fulltext) into l_clob_length from v$sqlarea where sql_id=sqlid;
while l_pos
select DBMS_LOB.SUBSTR(sql_fulltext,l_amount,l_pos) into l_buffer from v$sqlarea where sql_id=sqlid;
dbms_output.put(l_buffer);
l_pos:=l_pos+l_amount;
end loop;
dbms_output.put_line(‘ ‘);
end;
/
spool off
exit
RAY
}
func_help(){
echo “–from specifying how to get sqltext,memery or hist can be used.default momery!!”
echo “–sqlid specify a sql_id”
echo “for example:”
echo “get_fulltext.sh –from=momery –sqlid=*********”
}
#get parameter
argvs=($@)
for i in ${argvs[@]}
do
case `echo $i | awk -F ‘=’ ‘{print $1}’ | awk -F ‘–‘ ‘{print $2}’| tr [a-z] [A-Z]` in
FROM)
fm=`echo $i | awk -F ‘=’ ‘{print $2}’ | tr [a-z] [A-Z]`
;;
SQLID)
sqlid=`echo $i | awk -F ‘=’ ‘{print $2}’ `
;;
HELP)
func_help
exit 1
esac
done
if [ ! ${fm} ]; then
fm=’MOMERY’
fi
if [ ! ${sqlid} ]; then
echo “The sql_id must be specified!!”
exit 1
fi
##exec script
if [ ${fm} == “HIST” ];then
FromHist “${sqlid}”
elif [ ${fm} == “MOMERY” ];then
FromMomery “${sqlid}”
else
echo “then type of parameter only are HIST or MOMERY!!”
fi
感谢各位的阅读!关于“如何获取完整的sqltext脚本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
select DBMS_LOB.SUBSTR(sql_fulltext,l_amount,l_pos) into l_buffer from v$sqlarea where sql_id=sqlid;
dbms_output.put(l_buffer);
l_pos:=l_pos+l_amount;
end loop;
dbms_output.put_line(‘ ‘);
end;
/
spool off
exit
RAY
}
func_help(){
echo “–from specifying how to get sqltext,memery or hist can be used.default momery!!”
echo “–sqlid specify a sql_id”
echo “for example:”
echo “get_fulltext.sh –from=momery –sqlid=*********”
}
#get parameter
argvs=($@)
for i in ${argvs[@]}
do
case `echo $i | awk -F ‘=’ ‘{print $1}’ | awk -F ‘–‘ ‘{print $2}’| tr [a-z] [A-Z]` in
FROM)
fm=`echo $i | awk -F ‘=’ ‘{print $2}’ | tr [a-z] [A-Z]`
;;
SQLID)
sqlid=`echo $i | awk -F ‘=’ ‘{print $2}’ `
;;
HELP)
func_help
exit 1
esac
done
if [ ! ${fm} ]; then
fm=’MOMERY’
fi
if [ ! ${sqlid} ]; then
echo “The sql_id must be specified!!”
exit 1
fi
##exec script
if [ ${fm} == “HIST” ];then
FromHist “${sqlid}”
elif [ ${fm} == “MOMERY” ];then
FromMomery “${sqlid}”
else
echo “then type of parameter only are HIST or MOMERY!!”
fi感谢各位的阅读!关于“如何获取完整的sqltext脚本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
本篇内容介绍了“数据库备份的相关概念有哪些”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!一、备份的类型备份的类型可以分为两种:物理备份和逻辑备份。(1)物理备份…