溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ORACLE Flashback Query偽列

發(fā)布時間:2020-08-08 18:25:49 來源:ITPUB博客 閱讀:202 作者:Davis_itpub 欄目:關(guān)系型數(shù)據(jù)庫
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> &nbsp; &nbsp; 標準Flashback Query的功能是查詢過去某個時間點對象中保存的記錄信息,在當(dāng)前時間與指定的過去某個時間點之間,對象可能做過多次修改,如果希望看到這期間的每一次修改,Oracle提供了Flashback Version Query。 </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> &nbsp; &nbsp; Flashback Version Query也是以SELECT子句的形式調(diào)用,其用法并不比AS OF復(fù)雜,與其類似,只需要在標準SELECT查詢后面附加<b style="background-color:inherit;">VERSIONS BETWEEN TIMESTAMP[/SCN] START AND END</b>子句即可。通過VERSIONS BETWEEN能夠查看指定時間段內(nèi)UNDO表空間中記錄的不同版本(<b style="background-color:inherit;">注意,只包括被提交的記錄</b>)。記錄在Version Query中可能會是一對多的關(guān)系,如某些記錄如果被修改過多次并分別提交,那么在查詢的時候,如果修改的操作是在指定的時間段(或SCN)內(nèi)進行的,則記錄每次修改的結(jié)果都會被顯示出來,這倒是比較有利于我們對數(shù)據(jù)的修改進行對比,查看數(shù)據(jù)究竟是如何變化的。 </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> <br /> </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> &nbsp; &nbsp; Version Query中提供了多個偽列,如表所示。 </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> &nbsp; &nbsp; 表 &nbsp; &nbsp; Flashback Query中Version Query的偽列說明 </p> <div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> <table border="1" cellpadding="2" cellspacing="0" style="font-size:inherit;margin-top:10px;margin-bottom:10px;width:607px;background-color:inherit;"> <tbody style="background-color:inherit;"> <tr style="background-color:inherit;"> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:164px;"> <p style="background-color:inherit;"> <span lang="EN-US" style="background-color:inherit;"><span style="background-color:inherit;">VERSIONS_STARTSCN<br style="background-color:inherit;" /> VERSIONS_STARTTIME</span></span> </p> </td> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:401px;"> <p style="background-color:inherit;"> <span style="background-color:inherit;">該條記錄操作時的<span lang="EN-US" style="background-color:inherit;">SCN</span>或時間,如果為空,表示該行記錄是在查詢范圍外創(chuàng)建的</span> </p> </td> </tr> <tr style="background-color:inherit;"> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:164px;"> <p style="background-color:inherit;"> <span lang="EN-US" style="background-color:inherit;"><span style="background-color:inherit;">VERSIONS_ENDSCN</span></span> </p> <p style="background-color:inherit;"> <span lang="EN-US" style="background-color:inherit;"><span style="background-color:inherit;">VERSIONS_ENDTIME</span></span> </p> </td> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:401px;"> <p style="background-color:inherit;"> <span style="background-color:inherit;">該條記錄失效時的<span lang="EN-US" style="background-color:inherit;">SCN</span>或時間,如果為空,說明記錄當(dāng)前時間在當(dāng)前表內(nèi)不存在,或者已經(jīng)被刪除了,可以配合著<span lang="EN-US" style="background-color:inherit;">VERSIONS_OPERATION</span>列來看,如果<span lang="EN-US" style="background-color:inherit;">VERSIONS_OPERATION</span>列值為<span lang="EN-US" style="background-color:inherit;">D</span>,說明該列已被刪除,如果該列為空,則說明記錄在這段時間無操作</span> </p> </td> </tr> <tr style="background-color:inherit;"> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:164px;"> <p style="background-color:inherit;"> <span lang="EN-US" style="background-color:inherit;"><span style="background-color:inherit;">VERSIONS_XID</span></span> </p> </td> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:401px;"> <p style="background-color:inherit;"> <span style="background-color:inherit;">該操作的事務(wù)<span lang="EN-US" style="background-color:inherit;">ID</span></span> </p> </td> </tr> <tr style="background-color:inherit;"> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:164px;"> <p style="background-color:inherit;"> <span lang="EN-US" style="background-color:inherit;"><span style="background-color:inherit;">VERSIONS_OPERATION</span></span> </p> </td> <td style="word-break:break-all;border:1px solid #999999;padding:5px 16px 5px 12px;min-height:25px;min-width:25px;height:25px;background-color:inherit;width:401px;"> <p style="background-color:inherit;"> <span style="background-color:inherit;">對該行執(zhí)行的操作:<span lang="EN-US" style="background-color:inherit;">I</span>表示<span lang="EN-US" style="background-color:inherit;">INSERT</span>,<span lang="EN-US" style="background-color:inherit;">D</span>表示<span lang="EN-US" style="background-color:inherit;">DELETE</span>,<span lang="EN-US" style="background-color:inherit;">U</span>表示<span lang="EN-US" style="background-color:inherit;">UPDATE</span></span> </p> <p style="background-color:inherit;"> <span style="background-color:inherit;">提示:對于索引鍵的<span lang="EN-US" style="background-color:inherit;">update</span>操作,版本查詢可能會將其識別成兩個操作:<span lang="EN-US" style="background-color:inherit;">DELETE</span>和<span lang="EN-US" style="background-color:inherit;">INSERT</span></span> </p> </td> </tr> </tbody> </table> </div> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> <br /> </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> 相關(guān)知識點: </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> &nbsp; &nbsp; 什么是偽列?<span style="background-color:inherit;line-height:1.5;">我們都知道在創(chuàng)建表時必須指定列名、列類型等信息,這些顯式指定的列就是標準的列,在查詢時這些列能夠被SELECT語句顯示出來。除此之外,還有一種列類型,這些列并不存在于表定義中,如你通過DESC TBLNAME查看時看不到這些列的定義,但通過SELECT語句卻可以查詢這些列的內(nèi)容,這種列就是Oracle提供的偽列(如SYSDATE之類系統(tǒng)函數(shù)不是偽列)。</span> </p> <p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"> 偽列也并不是在任何查詢時都適用,有些列只有特殊的查詢語句中才能夠顯示,如上述表格中提供的6列就僅在使用Versions Query時才能夠調(diào)用。除此之外還有一些比較常用的ROWNUM、LEVEL等。 </p>
向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI