Monday, August 16, 2021

Introduction to Oracle Blockchain Tables in 21c

When I first heard that Oracle is now available in blockchain few years back, I fell from my chair in awe that how quickly they have adopted this new bleeding edge technology. I thought now Oracle corporation would also release its own cryptocurrency too. But then I learned that a blockchain oracle is not that Oracle. 


A blockchain oracle is just a service which inputs required information to smart contracts. A smart contract is just a program in blockchain which creates a immutable agreement between stakeholders without a third party.

Anyway, at last Oracle has dipped its feet into the blockchain technology it seems. In Oracle 21c, we have now something called as blockchain tables. Blockchain is simply a linked chain of blocks which store ledger of transactions verified and duplicated by all the nodes based on a complex cryptographic algorithm. This transparency, decentralization, and cryptographic foundation makes it more secure and eliminates the need of third parties. 

Oracle blockchain is not really that decentralized. It centralized the whole blockchain within the Oracle database. Blocks in a blockchain table are chained together by row hashes. You can only insert data into these tables. Rows can be deleted but only restricted to some retention value.


CREATE BLOCKCHAIN TABLE cardano_ledger (ada_id NUMBER, ada_tokens NUMBER)

                     NO DROP UNTIL 365 DAYS IDLE

                     NO DELETE LOCKED

                     HASHING USING "SHA2_512" VERSION "v1"



You can then check attributes of blockchain table in user_blockchain_tables.


You can delete rows in a blockchain table only by using the DBMS_BLOCKCHAIN_TABLE package, and only rows that are outside the retention period. You can only increase the retention period and not decrease it.


DECLARE

   NUMBER_ROWS NUMBER;

BEGIN

   DBMS_BLOCKCHAIN_TABLE.DELETE_EXPIRED_ROWS('TestUser','cardano_ledger', null, NUMBER_ROWS);

   DBMS_OUTPUT.PUT_LINE('Number of rows deleted=' || NUMBER_ROWS);

END;

/  

 

And you cannot truncate a blockchain table in Oracle database.


Now does Oracle blockchain table is really a blockchain? It has compromised decentralization and it conditionally mutable. I will leave the decision to you. 


For more practice of Oracle blockchain table, check the Oracle Docs.


No comments: