# Transaction 下列选项中,哪个可以正确的保证 channel 表和 posts 表的同步修改? ## 答案 ```sql begin; insert into posts(title, content) select ?, ?; update channel set posts = posts +1 where channel_id = ?; commit; ``` ## 选项 ### 没有 commit ```sql begin; insert into posts(title, content) select ?, ?; update channel set posts = posts +1 where channel_id = ?; end; ``` ### 没有创建事务 ```sql insert into posts(title, content) select ?, ?; update channel set posts = posts +1 where channel_id = ?; commit; ``` ### 多次提交 ```sql begin; insert into posts(title, content) select ?, ?; commit; update channel set posts = posts +1 where channel_id = ?; commit; ```