Oracle 19c & 21c required (19.11 onwards with minimal compatible 19.11)
[oracle@ol8 ~]$ sql donghua/password@pdb1
SQLcl: Release 20.4 Production on Tue Apr 27 20:06:12 2021
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Last Successful login time: Tue Apr 27 2021 20:06:13 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.11.0.0.0
SQL> select value from v$parameter where name='compatible';
VALUE
__________
19.11.0
Create & Drop Immutable table
SQL> CREATE IMMUTABLE TABLE trade_ledger (id NUMBER, luser VARCHAR2(40), value NUMBER)
2 NO DROP UNTIL 40 DAYS IDLE
3 NO DELETE UNTIL 100 DAYS AFTER INSERT;
Immutable TABLE created.
SQL> -- Empty immutable table or idle > 40 days can be dropped
SQL> drop table trade_ledger;
Table TRADE_LEDGER dropped.
Create immutable table & populate data
SQL> CREATE IMMUTABLE TABLE trade_ledger (id NUMBER, luser VARCHAR2(40), value NUMBER)
2 NO DROP UNTIL 40 DAYS IDLE
3 NO DELETE UNTIL 100 DAYS AFTER INSERT;
Immutable TABLE created.
SQL> insert into trade_ledger values (1,'donghua',100);
1 row inserted.
SQL> commit;
Commit complete.
Verify these prohibit actions
SQL> update trade_ledger set value=200 where id=1;
Error starting at line : 1 in command -
update trade_ledger set value=200 where id=1
Error at Command Line : 1 Column : 8
Error report -
SQL Error: ORA-05715: operation not allowed on the blockchain or immutable table
SQL> delete from trade_ledger;
Error starting at line : 1 in command -
delete from trade_ledger
Error at Command Line : 1 Column : 13
Error report -
SQL Error: ORA-05715: operation not allowed on the blockchain or immutable table
SQL> truncate table trade_ledger;
Error starting at line : 1 in command -
truncate table trade_ledger
Error report -
ORA-05715: operation not allowed on the blockchain or immutable table
SQL> drop table trade_ledger;
Error starting at line : 1 in command -
drop table trade_ledger
Error report -
ORA-05723: drop blockchain or immutable table TRADE_LEDGER not allowed
Query Immutable table data dictionary
SQL> select * from user_immutable_tables;
TABLE_NAME ROW_RETENTION ROW_RETENTION_LOCKED TABLE_INACTIVITY_RETENTION
_______________ ________________ _______________________ _____________________________
TRADE_LEDGER 100 NO 40