关于Oracle Blockchain Table的一点知识
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
本文链接地址: 关于Oracle Blockchain Table的一点知识
今年发布的Oracle Database 20c版本中引入了很多Niubility的功能;其中对于区块链的支持无疑是非常好的;这算是安全方面的一个增强吧;首先我们来看看具体情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
SQL> create blockchain table test0426 (object_name varchar2(128),object_id number) 2 no drop until 10000 days idle 3 no delete locked 4 hashing using "SHA2_512" VERSION "v1"; create blockchain table test0426 (object_name varchar2(128),object_id number) * ERROR at line 1: ORA-05729: blockchain table cannot be created in root container SQL> alter session set container=killdb; Session altered. SQL> create blockchain table test0426 (object_name varchar2(128),object_id number) 2 no drop until 10000 days idle 3 no delete locked 4 hashing using "SHA2_512" VERSION "v1"; Table created. SQL> insert into test0426 values('enmotech',9999999); 1 row created. Elapsed: 00:00:00.00 SQL> insert into test0426 values('yunhe',111111); 1 row created. Elapsed: 00:00:00.00 SQL> commit; Commit complete. SQL> insert into test0426 select object_name,object_id from dba_objects; insert into test0426 select object_name,object_id from dba_objects * ERROR at line 1: ORA-05715: operation not allowed on the blockchain table SQL> delete from test0426; delete from test0426 * ERROR at line 1: ORA-05715: operation not allowed on the blockchain table |
可以看到一定定义好之后,在规定的policy 时间范围内,是不允许进行一些操作的,比如delete和drop。那么Oracle如何实现区块链table机制呢? 这里我们来稍微深入研究一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SQL> select dbms_rowid.rowid_object(rowid) object_id, 2 dbms_rowid.rowid_relative_fno(rowid) file_id, 3 dbms_rowid.rowid_block_number(rowid) block_id, 4 dbms_rowid.rowid_row_number(rowid) num, 5 t.* 6 from test0426 t 7 order by 2, 3, 4 8 / OBJECT_ID FILE_ID BLOCK_ID NUM OBJECT_NAME OBJECT_ID ---------- ---------- ---------- ---------- ------------------------------ ---------- 74652 1 36065 0 enmotech 9999999 74652 1 36065 1 yunhe 111111 Elapsed: 00:00:00.03 SQL> |
这里插入的2行数据分布在上面block中;我们来dump 该数据块看看情况;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
Block header dump: 0x00408ce1 Object id on Block? Y seg/obj: 0x1239c csc: 0x00000000008da3bf itc: 2 flg: O typ: 1 - DATA fsl: 0 fnx: 0x0 ver: 0x01 Itl Xid Uba Flag Lck Scn/Fsc 0x01 0x0002.014.000002e2 0x024005a7.00cb.34 --U- 2 fsc 0x0000.008da3cf 0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000 bdba: 0x00408ce1 data_block_dump,data header at 0x7fab1fb2405c =============== tsiz: 0x1fa0 hsiz: 0x16 pbl: 0x7fab1fb2405c 76543210 flag=-------- ntab=1 nrow=2 frre=-1 fsbo=0x16 fseo=0x1e5a avsp=0x1eb6 tosp=0x1eb6 0xe:pti[0] nrow=2 offs=0 0x12:pri[0] offs=0x1ee9 0x14:pri[1] offs=0x1e5a block_row_dump: tab 0, row 0, @0x1ee9 tl: 108 fb: --H-FL-- lb: 0x1 cc: 8 col 0: [ 8] 65 6e 6d 6f 74 65 63 68 col 1: [ 5] c4 0a 64 64 64 col 2: [ 2] c1 02 col 3: [ 2] c1 1e col 4: [ 2] c1 02 col 5: [13] 78 78 04 19 10 18 05 22 81 c5 50 14 3c col 6: [ 1] 80 col 7: [64] bf e1 90 54 56 c6 eb 67 8e d2 c7 3c 94 eb 4e 75 61 5a 5a 53 35 72 1f 71 8c f5 76 a2 8d 83 5d 14 ae 9c a9 79 b3 61 82 b0 7f 33 0e a0 66 6b 1b 85 7a b9 5c ed e0 cb 76 c5 d2 33 e1 2b e8 3d 80 75 tab 0, row 1, @0x1e5a tl: 104 fb: --H-FL-- lb: 0x1 cc: 8 col 0: [ 5] 79 75 6e 68 65 col 1: [ 4] c3 0c 0c 0c col 2: [ 2] c1 02 col 3: [ 2] c1 1e col 4: [ 2] c1 03 col 5: [13] 78 78 04 19 10 18 05 23 08 08 68 14 3c col 6: [ 1] 80 col 7: [64] 48 4c 69 ef be 77 97 1b ca bd 72 6d d4 35 89 e6 14 04 26 5a 08 8e 98 29 1b 1c 0c 4b 7f 71 ea 73 13 cc 55 6d ad 94 56 68 9f 7b 52 5e 30 10 19 d1 b3 76 a7 fc c3 c6 b6 62 25 0b 7b 09 0e 90 1f dd end_of_block_dump |
从结构上来看其实跟普通data block没有任何区别;其中唯一的不同点是:我这个表明明是2个列;dump为什么显示一共有8个列呢?另外6个列是什么呢 ?
要回答这个问题,非常easy;你可以查询官方文档或者10046 event跟踪一下即可;我个人喜欢研究,因此跟踪一下看看吧:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
SQL> alter session set "_blockchainTracing"=1; Session altered. Elapsed: 00:00:00.01 SQL> oradebug setmypid Statement processed. SQL> oradebug event 10046 trace name context forever,level 12 Statement processed. SQL> insert into test0426 values('killdb.com',88888888); 1 row created. Elapsed: 00:00:00.00 SQL> commit; Commit complete. Elapsed: 00:00:00.02 SQL> oradebug tracefile_name /opt/oracle/diag/rdbms/enmotech/enmotech/trace/enmotech_ora_67810.trc SQL> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
PARSING IN CURSOR #140372932545384 len=289 dep=1 uid=0 oct=3 lid=0 tim=231702182940 hv=3089718337 ad='64b2bf90' sqlid='9yb6apaw2kr21' SELECT "ORABCTAB_INST_ID$", "ORABCTAB_CHAIN_ID$", "ORABCTAB_SEQ_NUM$", "ORABCTAB_CREATION_TIME$", "ORABCTAB_USER_NUMBER$", "ORABCTAB_HASH$", "ORABCTAB_SIGNATURE$", "ORABCTAB_SIGNATURE_ALG$", "ORABCTAB_SIGNATURE_CERT$", "ORABCTAB_SPARE$" from "SYS"."TEST0426" where rowid = :lrid END OF STMT PARSE #140372932545384:c=704,e=1191,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702182940 BINDS #140372932545384: Bind#0 oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=3952 off=0 kxsbbbfp=7fab1e3131b0 bln=3950 avl=13 flg=05 value=00008CE1.0002.0001 ++++ 00008CE1 -> 36065 EXEC #140372932545384:c=1697,e=1836,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=1793147655,tim=231702184943 FETCH #140372932545384:c=30,e=30,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,plh=1793147655,tim=231702184997 STAT #140372932545384 id=1 cnt=1 pid=0 pos=1 obj=74652 op='TABLE ACCESS BY USER ROWID TEST0426 (cr=1 pr=0 pw=0 str=1 time=24 us)' ===================== PARSING IN CURSOR #140373026473488 len=162 dep=1 uid=0 oct=3 lid=0 tim=231702185954 hv=1784484686 ad='6cab9bc8' sqlid='bvggpqdp5u4uf' select max_seq_number, hashval_position rom sys.blockchain_table_chain$ where obj#=:1 and inst_id = :2 and chain_id = :3 END OF STMT PARSE #140373026473488:c=774,e=763,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702185952 BINDS #140373026473488: Bind#0 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=72 off=0 kxsbbbfp=7fab1ec08f48 bln=22 avl=04 flg=05 value=74652 Bind#1 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=24 kxsbbbfp=7fab1ec08f60 bln=22 avl=02 flg=01 value=1 Bind#2 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=48 kxsbbbfp=7fab1ec08f78 bln=22 avl=02 flg=01 value=29 EXEC #140373026473488:c=1809,e=1556,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=1612174689,tim=231702187699 WAIT #140373026473488: nam='db file sequential read' ela= 148 file#=9 block#=36073 blocks=1 obj#=10902 tim=231702187900 WAIT #140373026473488: nam='db file sequential read' ela= 95 file#=9 block#=36081 blocks=1 obj#=10901 tim=231702188059 FETCH #140373026473488:c=376,e=375,p=2,cr=2,cu=0,mis=0,r=1,dep=1,og=4,plh=1612174689,tim=231702188091 ===================== PARSING IN CURSOR #140372922778880 len=177 dep=1 uid=0 oct=6 lid=0 tim=231702188448 hv=3455936715 ad='67fb1ec0' sqlid='5b1pq6m6zuu6b' update "SYS"."TEST0426" set orabctab_inst_id$ = :1, orabctab_chain_id$ = :2, orabctab_seq_num$ = :3, orabctab_user_number$ = :4, ORABCTAB_CREATION_TIME$ = :5 where rowid = :lrid END OF STMT PARSE #140372922778880:c=250,e=250,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702188447 BINDS #140372922778880: Bind#0 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=04 fl2=0000 frm=00 csi=00 siz=112 off=0 kxsbbbfp=7fab1ec82f90 bln=22 avl=02 flg=05 value=1 Bind#1 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=04 fl2=0000 frm=00 csi=00 siz=0 off=24 kxsbbbfp=7fab1ec82fa8 bln=22 avl=02 flg=01 value=29 Bind#2 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=04 fl2=0000 frm=00 csi=00 siz=0 off=48 kxsbbbfp=7fab1ec82fc0 bln=22 avl=02 flg=01 value=3 Bind#3 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=04 fl2=0000 frm=00 csi=00 siz=0 off=72 kxsbbbfp=7fab1ec82fd8 bln=22 avl=01 flg=01 value=0 Bind#4 oacdty=181 mxl=13(13) mxlc=00 mal=00 scl=09 pre=00 oacflg=04 fl2=8000000 frm=00 csi=00 siz=0 off=96 kxsbbbfp=7fab1ec82ff0 bln=13 avl=13 flg=01 value=25-APR-20 03.52.11.322791000 PM +00:00 Bind#5 oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=3952 off=0 kxsbbbfp=7fab1ec81070 bln=3950 avl=13 flg=05 value=00008CE1.0002.0001 EXEC #140372922778880:c=1184,e=1346,p=0,cr=0,cu=1,mis=1,r=1,dep=1,og=4,plh=3168479191,tim=231702189837 STAT #140372922778880 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE TEST0426 (cr=0 pr=0 pw=0 str=1 time=153 us)' STAT #140372922778880 id=2 cnt=1 pid=1 pos=1 obj=74652 op='TABLE ACCESS BY USER ROWID TEST0426 (cr=0 pr=0 pw=0 str=1 time=2 us)' CLOSE #140372922778880:c=4,e=4,dep=1,type=0,tim=231702189992 ===================== PARSING IN CURSOR #140372922778880 len=299 dep=1 uid=0 oct=3 lid=0 tim=231702190449 hv=3298906438 ad='6e832800' sqlid='26ch5yg2a2na6' SELECT "OBJECT_NAME", "OBJECT_ID", "ORABCTAB_INST_ID$", "ORABCTAB_CHAIN_ID$", "ORABCTAB_SEQ_NUM$", "ORABCTAB_CREATION_TIME$", "ORABCTAB_USER_NUMBER$", "ORABCTAB_HASH$", "ORABCTAB_SIGNATURE$", "ORABCTAB_SIGNATURE_ALG$", "ORABCTAB_SIGNATURE_CERT$" from "SYS"."TEST0426" where rowid = :lrid END OF STMT PARSE #140372922778880:c=419,e=419,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702190448 BINDS #140372922778880: Bind#0 oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=3952 off=0 kxsbbbfp=7fab1ec10410 bln=3950 avl=13 flg=05 value=00008CE1.0002.0001 EXEC #140372922778880:c=788,e=845,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=1793147655,tim=231702191403 FETCH #140372922778880:c=22,e=22,p=0,cr=1,cu=0,mis=0,r=1,dep=1,og=4,plh=1793147655,tim=231702191441 STAT #140372922778880 id=1 cnt=1 pid=0 pos=1 obj=74652 op='TABLE ACCESS BY USER ROWID TEST0426 (cr=1 pr=0 pw=0 str=1 time=16 us)' computed hash for new row: newlen=64 newHash=857FFC93C6F119FACEF5488CD336D51B9F31527BD5C008AABAF30B58F4444900E1DBD5EFAFE7BAFA4A8FBA4F5A5DF52333FD05F400310BFF7CB182C28251CA7D ===================== PARSING IN CURSOR #140372932119360 len=67 dep=1 uid=0 oct=6 lid=0 tim=231702192055 hv=1767288041 ad='69774fd0' sqlid='8gsu7v9npdb79' update "SYS"."TEST0426" set orabctab_hash$ = :1 where rowid = :lrid END OF STMT PARSE #140372932119360:c=471,e=471,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702192054 BINDS #140372932119360: Bind#0 oacdty=23 mxl=128(64) mxlc=00 mal=00 scl=00 pre=00 oacflg=14 fl2=0000 frm=00 csi=00 siz=128 off=0 kxsbbbfp=7ffea1721260 bln=128 avl=64 flg=09 value=857FFC93C6F119FACEF5488CD336D51B9F31527BD5C008AABAF30B58F4444900E1DBD5EFAFE7BAFA4A8FBA4F5A5DF52333FD05F400310BFF7CB182C28251CA Bind#1 oacdty=208 mxl=3950(3950) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=3952 off=0 kxsbbbfp=7fab1ec0f3f0 bln=3950 avl=13 flg=05 value=00008CE1.0002.0001 EXEC #140372932119360:c=1207,e=1185,p=0,cr=0,cu=1,mis=1,r=1,dep=1,og=4,plh=3168479191,tim=231702193350 STAT #140372932119360 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE TEST0426 (cr=0 pr=0 pw=0 str=1 time=28 us)' STAT #140372932119360 id=2 cnt=1 pid=1 pos=1 obj=74652 op='TABLE ACCESS BY USER ROWID TEST0426 (cr=0 pr=0 pw=0 str=1 time=3 us)' ===================== PARSING IN CURSOR #140372933257848 len=164 dep=1 uid=0 oct=6 lid=0 tim=231702194112 hv=1588782807 ad='6e9e7c10' sqlid='4hc26wpgb5tqr' update sys.blockchain_table_chain$ set hashval_position =:1, max_seq_number =:2 where obj#=:3 and inst_id = :4 and chain_id = :5 END OF STMT PARSE #140372933257848:c=655,e=656,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=231702194111 BINDS #140372933257848: Bind#0 oacdty=23 mxl=128(64) mxlc=00 mal=00 scl=00 pre=00 oacflg=10 fl2=0000 frm=00 csi=00 siz=128 off=0 kxsbbbfp=7ffea171e7e0 bln=128 avl=64 flg=09 value=857FFC93C6F119FACEF5488CD336D51B9F31527BD5C008AABAF30B58F4444900E1DBD5EFAFE7BAFA4A8FBA4F5A5DF52333FD05F400310BFF7CB182C28251CA Bind#1 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=96 off=0 kxsbbbfp=7fab1ec11320 bln=22 avl=02 flg=05 value=3 Bind#2 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=24 kxsbbbfp=7fab1ec11338 bln=22 avl=04 flg=01 value=74652 Bind#3 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=48 kxsbbbfp=7fab1ec11350 bln=22 avl=02 flg=01 value=1 Bind#4 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=00 fl2=0000 frm=00 csi=00 siz=0 off=72 kxsbbbfp=7fab1ec11368 bln=22 avl=02 flg=01 value=29 EXEC #140372933257848:c=1914,e=1848,p=0,cr=1,cu=1,mis=1,r=1,dep=1,og=4,plh=2019081831,tim=231702196060 STAT #140372933257848 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE BLOCKCHAIN_TABLE_CHAIN$ (cr=1 pr=0 pw=0 str=1 time=90 us)' STAT #140372933257848 id=2 cnt=1 pid=1 pos=1 obj=10902 op='INDEX RANGE SCAN BLOCKCHAIN_TABLE_CHAIN$_IDX (cr=1 pr=0 pw=0 str=1 time=24 us cost=1 size=1054 card=1)' WAIT #140372923406352: nam='Disk file operations I/O' ela= 194 FileOperation=8 fileno=0 filetype=8 obj#=74652 tim=231702196924 EXEC #140372923406352:c=14726,e=15345,p=2,cr=5,cu=4,mis=0,r=0,dep=0,og=0,plh=0,tim=231702196968 CLOSE #140372933257848:c=9,e=9,dep=0,type=0,tim=231702197172 CLOSE #140372932119360:c=3,e=4,dep=0,type=0,tim=231702197208 CLOSE #140372922778880:c=4,e=4,dep=0,type=0,tim=231702197226 STAT #140373026473488 id=1 cnt=1 pid=0 pos=1 obj=10900 op='TABLE ACCESS BY GLOBAL INDEX ROWID BATCHED BLOCKCHAIN_TABLE_CHAIN$ PARTITION: ROW LOCATION ROW LOCATION (cr=2 pr=2 pw=0 str=1 time=382 us cost=1 size=1054 card=1)' STAT #140373026473488 id=2 cnt=1 pid=1 pos=1 obj=10902 op='INDEX RANGE SCAN BLOCKCHAIN_TABLE_CHAIN$_IDX (cr=1 pr=1 pw=0 str=1 time=231 us cost=1 size=0 card=1)' CLOSE #140373026473488:c=58,e=58,dep=0,type=0,tim=231702197294 CLOSE #140372932545384:c=4,e=4,dep=0,type=0,tim=231702197309 WAIT #140372923406352: nam='SQL*Net message to client' ela= 4 driver id=1650815232 #bytes=1 p3=0 obj#=74652 tim=231702197332 WAIT #140372923406352: nam='SQL*Net more data to client' ela= 1 driver id=1650815232 #bytes=187 p3=0 obj#=74652 tim=231702197347 |
上述信息较多,但是关键点其实没多少;大致上我们可以看出Oracle 其实是通过在表上创建隐藏列来实现;这部分隐藏列的数据正常情况下是Oracle自动计算产生的,其中还有相关hash值;通过此种方法防止数据被篡改。
1 2 3 4 5 6 7 8 9 |
SQL> select * from sys.blockchain_table_chain$; OBJ# INST_ID CHAIN_ID EPOCH# HASHVAL_POSITION MIN_SEQ_NUMBER MAX_SEQ_NUMBER SPARE1 SPARE2 SPARE3 SPARE4 ---------- ---------- ---------- ---------- ------------------------------------------------------------------------------------- -------------- -------------- ---------- ---------- ---------- ---------- 74652 1 29 857FFC93C6F119FACEF5488CD336D51B9F31527BD5C008AABAF30B58F4444900E1DBD5EFAFE7BAFA4A8FB 3 A4F5A5DF52333FD05F400310BFF7CB182C28251CA7D 74652 1 4 A0EC42650475C31FD6610A4F31C4545B88BB3647EAF2105FDCA646ABC3EF0628FAF399E9602B3B66A9637 1 333A8F4D0AB96B8021FE770EEED4EBBBD1C71B8C68A |
而关于该字典表Oracle其实也是定义为了sharding table:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
CREATE TABLE "SYS"."BLOCKCHAIN_TABLE_CHAIN$" SHARING=METADATA ( "OBJ#" NUMBER NOT NULL ENABLE, "INST_ID" NUMBER NOT NULL ENABLE, "CHAIN_ID" NUMBER NOT NULL ENABLE, "EPOCH#" NUMBER, "HASHVAL_POSITION" RAW(2000), "MIN_SEQ_NUMBER" NUMBER, "MAX_SEQ_NUMBER" NUMBER, "SPARE1" NUMBER, "SPARE2" NUMBER, "SPARE3" NUMBER, "SPARE4" NUMBER ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE( BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SYSTEM" PARTITION BY LIST ("INST_ID") AUTOMATIC (PARTITION "BCTAB_INST_1" VALUES (1) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SYSTEM" ) |
当然关于区块链表还有一些约束条件和限制;大家请看官方文档即可。
这里我比较好奇的是;如果区块链table出现坏块了,怎么办?处理方法跟之前的手段一样吗?这里我人为模拟一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
SQL> select count(1) from test0426; COUNT(1) ---------- 4 SQL> alter system flush buffer_cache; System altered. SQL> select count(1) from test0426; select count(1) from test0426 * ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 9, block # 36066) ORA-01110: data file 9: '/opt/oracle/oradata/ENMOTECH/killdb/system01.dbf' SQL> ALTER SYSTEM SET EVENTS '10231 trace name context forever,level 10' ; System altered. SQL> select count(1) from test0426; COUNT(1) ---------- 3 |
可以看到这种跳过坏块的方法仍然可用;同时我们进一步通过bbed 工具来查看一下block结构和数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
BBED> set file 9 block 36065 FILE# 9 BLOCK# 36065 BBED> p *kdbr[0] rowdata[143] ------------ ub1 rowdata[143] @8005 0x2c BBED> x /rcnnncccccccccccc rowdata[143] @8005 ------------ flag@8005: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@8006: 0x01 cols@8007: 8 col 0[8] @8008: enmotech col 1[5] @8017: 9999999 col 2[2] @8023: 1 col 3[2] @8026: 29 col 4[2] @8029: .. col 5[13] @8032: xx....."..P.< col 6[1] @8046: . col 7[64] @8048: ...TV..g...<..NuaZZS5r.q..v...]....y.a...3..fk..z.\...v ..3.+.=.u |
不难看出,本质上来讲没有太大的区别;也就多了隐藏列而已;列的数据是Oracle自动计算的。对于实际的数据存储格式,跟以前完全一样。如下是关于区块链table相关的几个参数:
1 2 3 4 5 6 7 |
NAME VALUE DESCRIB ------------------------------ -------------------- ------------------------------------------------------------ _blockchain_txn_apis_enabled TRUE If true, the txn layer blockchain API'S kick in _blockchain_txn_test_lvl 0 blockchain txn test lvl _blockchainHeapSize 0 Set the heap size in bytes for blockchain _blockchainTracing 0 Set tracing for blockchain _blockchain_forced_off NOT_SET force off blockchain |
总的来讲比较简单;欢迎大家测试并进行分享!
Leave a Reply
You must be logged in to post a comment.