日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[20170410]快速找回触发器内容.txt

發(fā)布時間:2025/3/15 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [20170410]快速找回触发器内容.txt 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

[20170410]快速找回觸發(fā)器內(nèi)容.txt

--上午登錄發(fā)現(xiàn)一個是觸發(fā)器被人為刪除了,需要恢復(fù).鏈接http://www.itpub.net/thread-2084789-1-1.html.
--我提供幾個方法:1.取出備份的system數(shù)據(jù)文件,通過bbed之類的工具定位.2使用logminer 應(yīng)該也可以定位,表sys.source$.

--實際上還有1個簡單粗暴的方法,直接通過strings查詢歸檔日志.例子如下:

1.環(huán)境:
SYS@book> @ &r/ver1
PORT_STRING??????????????????? VERSION??????? BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx??????????? 11.2.0.4.0???? Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//我的測試環(huán)境很早建立的一個函數(shù).
CREATE OR REPLACE function SCOTT.p2p_distance(
??????????? p_latitude1 number,
??????????? p_longitude1 number,
??????????? p_latitude2 number,
??????????? p_longitude2 number) return number deterministic is
? earth_radius? number := 6371;
? pi_approx???? number := 3.1415197/180;
? lat_delta???? number := (p_latitude2-p_latitude1)*pi_approx;
? lon_delta???? number := (p_longitude2-p_longitude1)*pi_approx;
? arc?????????? number := sin(lat_delta/2) * sin(lat_delta/2) +
?????????????????????????????? sin(lon_delta/2) * sin(lon_delta/2) * cos(p_latitude1*pi_approx) * cos(p_latitude2*pi_approx);
begin
? return earth_radius * 2 * atan2(sqrt(arc), sqrt(1-arc));
end;
/

2.刪除它,恢復(fù)看看.
SYS@book> @ &r/logfile
GROUP# STATUS TYPE?????? MEMBER????????????????????????? IS_ GROUP# THREAD# SEQUENCE#?????? BYTES BLOCKSIZE MEMBERS ARC STATUS???? FIRST_CHANGE# FIRST_TIME????????? NEXT_CHANGE# NEXT_TIME
------ ------ ---------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
???? 1??????? ONLINE???? /mnt/ramdisk/book/redo01.log??? NO?????? 1?????? 1?????? 815??? 52428800?????? 512?????? 1 YES INACTIVE???? 13277272313 2017-04-08 16:00:41? 13277278586 2017-04-10 08:43:12
???? 2??????? ONLINE???? /mnt/ramdisk/book/redo02.log??? NO?????? 2?????? 1?????? 816??? 52428800?????? 512?????? 1 YES INACTIVE???? 13277278586 2017-04-10 08:43:12? 13277278900 2017-04-10 08:43:16
???? 3??????? ONLINE???? /mnt/ramdisk/book/redo03.log??? NO?????? 3?????? 1?????? 817??? 52428800?????? 512?????? 1 NO? CURRENT????? 13277278900 2017-04-10 08:43:16 2.814750E+14
???? 4??????? STANDBY??? /mnt/ramdisk/book/redostb01.log NO
???? 5??????? STANDBY??? /mnt/ramdisk/book/redostb02.log NO
???? 6??????? STANDBY??? /mnt/ramdisk/book/redostb03.log NO
???? 7??????? STANDBY??? /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

--//當前在線日志/mnt/ramdisk/book/redo03.log .

SYS@book> drop function SCOTT.p2p_distance;
Function dropped.

SYS@book> alter system checkpoint ;
System altered.

SYS@book> alter system checkpoint ;
System altered.

SYS@book> alter system checkpoint ;
System altered.
--//保證臟塊寫盤.

$ strings -3 /mnt/ramdisk/book/redo03.log > /tmp/aaa.txt

drop function SCOTT.p2p_distance
SCOTT
P2P_DISTANCE
ORA$BASE.,
YYYY-MM-DD HH24:MI:SS
YYYY-MM-DD HH24:MI:SS.FFHH.MI.SSXFF AM
HH.MI.SSXFF AM TZR
YYYY-MM-DD HH24:MI:SS.FF TZH:TZMAMERICANAMERICANGREGORIAN
BINARY
BINARY
AMERICA
AMERICA
BYTEFALSE
??? _H--------------------------------------
function p2p_distance(
??????????? p_latitude1 number,
??????????? p_longitude1 number,
??????????? p_latitude2 number,
??????????? p_longitude2 number) return number deterministic is
? earth_radius? number := 6371;
? pi_approx???? number := 3.1415197/180;
? la
t_delta???? number := (p_latitude2-p_latitude1)*pi_approx;
? lon_delta???? number := (p_longitude2-p_longitude1)*pi_approx;
? arc?????????? number := sin(lat_delta/2) * sin(lat_delta/2) +
?????????????????????????????? sin(lon_delta
6/2) * sin(lon_delta/2) * cos(p_latitude1*pi_approx) * cos(p_latitude2*pi_approx);
~~
begin
? return earth_radius * 2 * atan2(sqrt(arc), sqrt(1-arc));
end;
U7^M

--//ok,里面就有內(nèi)容.改寫一下就ok了:(注有一點點小錯誤,里面多了1個6,注意看下劃線)
CREATE OR REPLACE function SCOTT.p2p_distance(
??????????? p_latitude1 number,
??????????? p_longitude1 number,
??????????? p_latitude2 number,
??????????? p_longitude2 number) return number deterministic is
? earth_radius? number := 6371;
? pi_approx???? number := 3.1415197/180;
? lat_delta???? number := (p_latitude2-p_latitude1)*pi_approx;
? lon_delta???? number := (p_longitude2-p_longitude1)*pi_approx;
? arc?????????? number := sin(lat_delta/2) * sin(lat_delta/2) +
?????????????????????????????? sin(lon_delta/2) * sin(lon_delta/2) * cos(p_latitude1*pi_approx) * cos(p_latitude2*pi_approx);
begin
? return earth_radius * 2 * atan2(sqrt(arc), sqrt(1-arc));
end;
/

--//在引申一點,實際上你可以直接掃描system01.dbf文件找到對應(yīng)的內(nèi)容.正常業(yè)務(wù)數(shù)據(jù)庫一般不會有大量的dml對于sys.source$表.

SYS@book> column PARTITION_NAME noprint
SYS@book> select * from (select * from dba_extents where segment_name='SOURCE$' order by block_id desc) where rownum=1;
OWNER? SEGMENT_NAME???????? SEGMENT_TYPE?????? TABLESPACE_NAME???????????????? EXTENT_ID??? FILE_ID?? BLOCK_ID????? BYTES???? BLOCKS RELATIVE_FNO
------ -------------------- ------------------ ------------------------------ ---------- ---------- ---------- ---------- ---------- ------------
SYS??? SOURCE$????????????? TABLE????????????? SYSTEM???????????????????????????????? 79????????? 1????? 91520??? 8388608?????? 1024??????????? 1

--//最后1塊在91520.占用1024塊.
SYS@book> select (91520+1024-1)*8192 from dual ;
(91520+1024-1)*8192
-------------------
????????? 758112256

--//91520+1024=92544

$ dd if=/mnt/ramdisk/book/system01.dbf bs=8192 count=92544 | strings -3 > /tmp/bbb.txt
92544+0 records in
92544+0 records out
758120448 bytes (758 MB) copied, 11.8657 seconds, 63.9 MB/s

--//查詢可以找到如下:

function p2p_distance(
??? _H
???????????? p_latitude1 number,
??? _H
!??????????? p_longitude1 number,
??? _H
???????????? p_latitude2 number,
??? _H
@??????????? p_longitude2 number) return number deterministic is
??? _H
?? earth_radius? number := 6371;
??? _H
)? pi_approx???? number := 3.1415197/180;
??? _H
??? ?? lat_delta???? number := (p_latitude2-p_latitude1)*pi_approx;
??? _H
A? lon_delta???? number := (p_longitude2-p_longitude1)*pi_approx;
??? _H
@? arc?????????? number := sin(lat_delta/2) * sin(lat_delta/2) +
??? _H
~?????????????????????????????? sin(lon_delta/2) * sin(lon_delta/2) * cos(p_latitude1*pi_approx) * cos(p_latitude2*pi_approx);
??? _H
begin
??? _H
;? return earth_radius * 2 * atan2(sqrt(arc), sqrt(1-arc));
??? _H
end;,

--//編輯一下就ok了.感覺看歸檔日志更好一些.重新建立后

SCOTT@book> select p2p_distance(36.12, -86.67, 33.94, -118.4) from dual;

P2P_DISTANCE(36.12,-86.67,33.94,-118.4)
---------------------------------------
???????????????????????????? 2886.40705
--//與原來計算結(jié)果一樣.

總結(jié)

以上是生活随笔為你收集整理的[20170410]快速找回触发器内容.txt的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。