数据库什么时候把缓冲里的东西写入数据文件?

[复制链接]
查看11 | 回复4 | 2011-11-16 22:31:22 | 显示全部楼层 |阅读模式
做了几个小的操作,感觉有点迷惑?
步骤如下:
SQL> connect sys/system@repm as sysdba
已连接。
SQL>
SQL> select * from xys.tt;
AA BB CC
---------- ---------- ----------
test test test
test5test5test5
test2test2test2
test1test1test1
test3test3test3
SQL> alter tablespace users begin backup;
表空间已更改。
SQL> insert into xys.tt values('a' , 'a' , 'a');
已创建 1 行。
SQL> commit;
提交完成。
SQL> create table xys.t_ttt(aa varchar2(10)) tablespace users;
表已创建。
SQL> alter tablespace users end backup;
表空间已更改。
SQL> alter system checkpoint;
系统已更改。
SQL> insert into xys.tt values('b' , 'b' , 'b');
已创建 1 行。
SQL> select * from xys.tt;
AA BB CC
---------- ---------- ----------
test test test
test5test5test5
test2test2test2
test1test1test1
test3test3test3
a
a
a
b
b
b
已选择7行。
SQL> commit;
提交完成。
SQL>

1、执行alter tablespace users begin backup以后,还可以操作表空间,此时的操作应该在缓冲吧,没有写入数据文件吧?
2、insert into xys.tt values('b' , 'b' , 'b'); 插入数据以后,没有提交,也应该在缓冲吧,如果commit以后,是不是立即写入数据文件
总之数据库什么时候把缓冲里的东西写入数据文件?
回复

使用道具 举报

千问 | 2011-11-16 22:31:22 | 显示全部楼层
insert into xys.values('b','b','b')后,没有提交,但也不一定就没写入数据文件,就是提交也不一定就写到数据文件了。书上写了dbwr发生的几个先决条件
? The number of dirty buffers reaches a threshold value
? A process scans a specified number of blocks when scanning for free buffers and
cannot find any
? A timeout occurs (every three seconds)
? A checkpoint occurs (A checkpoint is a means of synchronizing the database
buffer cache with the data file. Checkpoints are covered in detail in the lesson
“Maintaining Redo Log Files.”)
回复

使用道具 举报

千问 | 2011-11-16 22:31:22 | 显示全部楼层
最初由 DemonSam 发布
[B]insert into xys.values('b','b','b')后,没有提交,但也不一定就没写入数据文件,就是提交也不一定就写到数据文件了。书上写了dbwr发生的几个先决条件
? The number of dirty buffers reaches a threshold value
? A process scans a specified number of blocks when scanning for free buffers and
cannot find any
? A timeout occurs (every three seconds)
? A checkpoint occurs (A checkpoint is a means of synchronizing the database
buffer cache with the data file. Checkpoints are covered in detail in the lesson
“Maintaining Redo Log Files.”) [/B]

A timeout occurs 以前没有听说过,是不是和检查点差不多呢,检查点不也是每隔一段时间出现一次
回复

使用道具 举报

千问 | 2011-11-16 22:31:22 | 显示全部楼层
最初由 DemonSam 发布
[B]insert into xys.values('b','b','b')后,没有提交,但也不一定就没写入数据文件,就是提交也不一定就写到数据文件了。书上写了dbwr发生的几个先决条件
? The number of dirty buffers reaches a threshold value
? A process scans a specified number of blocks when scanning for free buffers and
cannot find any
? A timeout occurs (every three seconds)
? A checkpoint occurs (A checkpoint is a means of synchronizing the database
buffer cache with the data file. Checkpoints are covered in detail in the lesson
“Maintaining Redo Log Files.”) [/B]

“没有提交,但也不一定就没写入数据文件“这句话有问题吧,没有提交应该是一定不会写入数据文件吧!我是这样理解的
回复

使用道具 举报

千问 | 2011-11-16 22:31:22 | 显示全部楼层
最初由 warehouse 发布
[B]
“没有提交,但也不一定就没写入数据文件“这句话有问题吧,没有提交应该是一定不会写入数据文件吧!我是这样理解的 [/B]

No, it's possible that before commit, dbwr write
dirty buffer to datafiles --- that's why there are
2 stages in instance recovery: roll forward -- applying redo log to datafiles; rollback -- clean
modified un-committed records.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行