Blockchain table 功能初始於 Oracle 21c 版本上發佈,隨後向前部署至 Oracle 19c 版本(19.10),並在後續 Oracle 23ai 版本上進行了問題的修復與功能的增強。
Blockchain table 的主要用途是提供防篡改、僅能附加資料的表格(Insert-Only)。 Blockchain table 中的每一筆資料行會透過加密雜湊(hash)的機制與前一筆資料行進行鏈結,因此可達到防篡改的機制。 如下圖所示,每一資料行都包含一個基於該行資料和鏈中前一行的雜湊值的加密雜湊值。

Blockchain table 與傳統的表格不同之處在於傳統表格可讓您進行修改或刪除資料,因此開發人員要使用稽核表和稽核追蹤等技術協助追蹤資料歷程。雖然這些方法可行,但開發人員需要自訂開發,且需要負擔責任以確保資料的正確性。 而 Blockchain table 只能進行資料的插入,所以可提供開發人員完整的資料歷程,且其資料不可變更並可進行驗證,這表示您可以信任資料的正確性。
Blockchain table 非常適合需要記錄完整變更歷程的資料,例如:
金融交易:確保金融交易的完整性,維護安全且不可篡改的賬本。
審計跟蹤:創建防篡改的審計跟蹤,以滿足法規遵從、內部審計和外部審查的需求。
供應鏈追蹤和溯源:監控商品在供應鍵中的流動,驗證商品的來源與歷史,這對於食品、藥品等行業至關重要。
病患醫療記錄:安全地存儲和共享患者記錄,確保資料的完整性、正確性與隱私。
公共記錄:維護不可篡改的公共記錄,如投票記錄,出生、死亡和婚姻記錄。
以下實際演示其基本功能:
創建 blockchain table:
|
drop table bct_v2;
create blockchain table bct_v2 ( id number, fruit varchar2(20), quantity number, created_date date, constraint bct_pk primary key (id) ) no drop until 16 days idle --此子句表示在 16 天內只要有新資料的插入,則該表格不能夠被刪除。 no delete until 16 days after insert --此子句表示每一筆新增的資料行,在 16 天內不能夠被刪除。 hashing using "SHA2_512" version "v2"; --使用雜湊演算法SHA2_512,並指定有具功能增強的 Blockchain table V2 版本。 |
新增資料至 blockchain table
|
SQL> insert into bct_v2 (id, fruit, quantity, created_date) values (1, 'apple', 20, sysdate);
SQL> commit; |
操作更新資料被拒
|
SQL> update bct_v2 set quantity = 10 where id=1;
SQL Error: ORA-05715: operation not allowed on the blockchain or immutable table |
操作刪除資料被拒
|
SQL> delete from bct_v2 where id = 1;
SQL Error: ORA-05715: operation not allowed on the blockchain or immutable table |
操作刪除表格被拒
|
SQL> drop table bct_v2;
ORA-05723: dropping BCT_V2, which is a non-empty blockchain or immutable table, is not allowed |
操作 truncate表格被拒
|
SQL> truncate table bct_v2;
ORA-05715: operation not allowed on the blockchain or immutable table |
這裡說明在使用 blockchain table 時需要考慮的事項:
舊版本上的許多問題在 Oracle 23ai 上獲得了修正
Blockchain table 的效能會比傳統表格要來的慢,這是因為有額外的運算負載
Blockchain table 可以進行索引或是分區操作
在對 Blockchain table 使用 Oracle Data Pump 工具時有一些限制,請參考連結:
Blockchain table 本身使用上的限制,請參考連結:
以下為總結使用 Blockchain table 的優勢:
不可篡改性:確保資料一旦寫入,無法被更改或刪除(可配置基於時間的資料刪除),提供可信賴的稽核追蹤。
與現有系統整合:無需單獨的區塊鏈基礎設施,就能無縫整合到現有的 Oracle 資料庫應用中。
效能與可擴充性:利用 Oracle 資料庫技術提供高效能和可擴充性。
安全性:提供內建的安全功能,包括加密和存取控制,以保護敏感資料。