如何验证GBase8s数据库ACID特性?
@font-face{ font-family:"Times New Roman"; } @font-face{ font-family:"宋体"; } @font-face{ font-family:"Calibri"; } @font-face{ font-family:"微软雅黑"; } @font-face{ font-family:"Consolas"; } @font-face{ font-family:"Courier New"; } p.MsoNormal{ mso-style-name:正文; mso-style-parent:""; margin:0pt; margin-bottom:.0001pt; mso-pagination:none; text-align:justify; text-justify:inter-ideograph; font-family:Calibri; mso-fareast-font-family:宋体; mso-bidi-font-family:'Times New Roman'; font-size:10.5000pt; mso-font-kerning:1.0000pt; } span.msoIns{ mso-style-type:export-only; mso-style-name:""; text-decoration:underline; text-underline:single; color:blue; } span.msoDel{ mso-style-type:export-only; mso-style-name:""; text-decoration:line-through; color:red; } table.MsoNormalTable{ mso-style-name:普通表格; mso-style-parent:""; mso-style-noshow:yes; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-family:'Times New Roman'; font-size:10.0000pt; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400; } table.MsoTableGrid{ mso-style-name:网格型; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-padding-alt:0.0000pt 5.4000pt 0.0000pt 5.4000pt; mso-border-top-alt:0.5000pt solid windowtext; mso-border-left-alt:0.5000pt solid windowtext; mso-border-bottom-alt:0.5000pt solid windowtext; mso-border-right-alt:0.5000pt solid windowtext; mso-border-insideh:0.5000pt solid windowtext; mso-border-insidev:0.5000pt solid windowtext; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:none; text-align:justify; text-justify:inter-ideograph; font-family:'Times New Roman'; font-size:10.0000pt; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400; } @page{mso-page-border-surround-header:no; mso-page-border-surround-footer:no;}@page Section0{ } div.Section0{page:Section0;}
事务原子性验证: Set environment sqlmode 'gbase'; --创建测试表,并插入数据 Drop table if exists test_acid_a; create table test_acid_a(id int,col1 int); insert into test_acid_a values(1,0); insert into test_acid_a values(2,0); insert into test_acid_a values(3,0); insert into test_acid_a values(4,0); insert into test_acid_a values(5,0); insert into test_acid_a values(6,0); insert into test_acid_a values(7,0); insert into test_acid_a values(8,0); insert into test_acid_a values(9,0); insert into test_acid_a values(10,0); insert into test_acid_a values(11,0); insert into test_acid_a values(12,0); select * from test_acid_a; --随机commit 和rollback --创建随机函数 drop function if exists sp_random; create function sp_random(m int,n int) returning int; define global seed decimal(10) default 1; define d decimal(20,0); let d =(seed * 1103515245)+ 12345; let seed =d - 4294967296 * TRUNC( d / 4294967296); if(mod(trunc(seed / 65536),n)<m) then return m; else return mod(trunc(seed/65536),n); end if; end function; --适配样例中的存储过程,实现随机commit\rollback drop procedure protest ; create procedure protest() define i int; define rand int; for i in (1 to 99999) loop begin work; update test_acid_a set col1=i where id=1; update test_acid_a set col1=i where id=2; update test_acid_a set col1=i where id=3; update test_acid_a set col1=i where id=4; update test_acid_a set col1=i where id=5; update test_acid_a set col1=i where id=6; update test_acid_a set col1=i where id=7; update test_acid_a set col1=i where id=8; update test_acid_a set col1=i where id=9; update test_acid_a set col1=i where id=10; update test_acid_a set col1=i where id=11; update test_acid_a set col1=i where id=12; select sp_random(1,99999) into rand from dual; if mod(rand,2)=1 then commit; else rollback; end if; end loop; end procedure; call protest(); 通过ctrl+c等方式中断运行,并查询每行的col1的都一致 select * from test_acid_a; | ||||||||||||
事务一致性验证 创建测试表,并插入数据 create table test_acid_c (id int,col1 varchar2 (10)); 登录不同会话,执行以下操作:
| ||||||||||||
事务隔离性验证 创建测试表,并插入数据 create table test_acid_i(id int,col varchar2(10)); 登录不同会话,执行以下操作:
| ||||||||||||
事务持久性验证 退出会话,重新登录后查询 select * from test_acid_i; --查询出两条记录 |
评论
有用 0
墨值悬赏

