Oracle 21c introduces a new feature called Blockchain Tables, which allows users to store and query data stored on a blockchain network directly in the database. This feature makes it easy to integrate blockchain data into Oracle-based applications, and enables users to leverage the security and immutability of blockchain technology while still using familiar SQL commands to access and manipulate the data.
In this article, we will take a closer look at Oracle Blockchain Tables and how they can be used to store and query blockchain data within the database. We will also provide an example of how to create and use a Blockchain Table in Oracle 21c.
To create a Blockchain Table in Oracle 21c, you first need to install the Oracle Blockchain Table Gateway, which is a separate component that provides access to the blockchain network. Once the Gateway is installed, you can use the CREATE TABLE
statement to create a Blockchain Table, as shown in the following example:
CREATE TABLE blockchain_table (
id NUMBER,
name VARCHAR2(50),
value NUMBER
)
BLOCKCHAIN ('my_blockchain_network');
In this example, we create a Blockchain Table called blockchain_table
with three columns: id
, name
, and value
. The BLOCKCHAIN
clause specifies the name of the blockchain network that the table will be connected to.
Once the Blockchain Table is created, you can use standard SQL statements to insert, update, and query the data stored in the table. For example, you can use the INSERT
statement to insert a new row into the table, as shown in the following example:
INSERT INTO blockchain_table (id, name, value)
VALUES (1, 'Alice', 100);
You can also use the SELECT
statement to retrieve data from the table, as shown in the following example:
SELECT * FROM blockchain_table WHERE value > 50;
This SELECT statement retrieves all rows from the blockchain_table
where the value of the value
column is greater than 50.
In addition to standard SQL statements, Oracle Blockchain Tables also support the use of Oracle Blockchain Functions, which allow users to invoke blockchain-specific operations and retrieve blockchain-specific information. For example, you can use the BLOCKCHAIN_TX_ID
function to retrieve the transaction ID of a row in the table, as shown in the following example:
SELECT BLOCKCHAIN_TX_ID(id) FROM blockchain_table WHERE id = 1;
This SELECT statement retrieves the transaction ID of the row with an id
Have a fun:)
Tomasz