Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Restart phenomenon of flip-flop of UPDATE type

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

SQL_1> create table mytest(id int );

Table created.

SQL_1>insert into mytest select 1 from dual;

1 line created.

create or replace trigger tri_mytest_u before update on mytest for each row

begin

dbms_output.put_line('old_value: '||:OLD.id);

dbms_output.put_line('new_value: '||:NEW.id);

5 end;

6 /

Trigger created

SQL_1>show errors;

No mistakes.

SQL_1>update mytest set id=id+1;

old_value: 1

new_value: 2

1 line updated.

SQL> set serveroutput on size 20000

SQL> set sqlprompt SQL_1

In new window 2 perform:

-------------------------------

SQL> set serveroutput on size 20000

SQL> set sqlprompt SQL_2

SQL_2>update mytest set id=id+1;

---------------------------------

SQL_1>commit;

Submission complete.

Window 2 Execution Results:

-------------------------

SQL_2>update mytest set id=id+1;

old_value: 1

new_value: 2

old_value: 2

new_value: 3

1 line updated.

SQL_2>select * from mytest;

ID

----------

3

Conclusion: Update triggers restart to read committed transaction information if wait occurs while updating data.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report