Data files are deleted directly from the operating system when the database is open
Because in a Linux system, a process that has previously opened the file still holds the appropriate file handle, and the file that you point to is still readable and writable,
File descriptors can be obtained from the/proc directory
If you close the database, the handle disappears
In the actual experiment, we found that the DBW0 process will hold the handle of all the data files when it is opened. However, only after the database has been written to the file is a true holding handle file, the file that has not been written to write operations is deleted from the operating system and the database cannot continue to read and write to the file
The experimental process in the virtual machine is as follows:
Taking exmple table space as an example to demonstrate
A
1. Restart the database to view the DBW0 process
[Root@oracle ~]# ps-ef |grep dbw0 |grep-v grep
Oracle 19362 1 0 10:50? 00:00:00 ORA_DBW0_ORCL
2. View the process of locking example01.dbf files
[Root@oracle ~]# lsof |grep Example
Oracle 19362 Oracle 23uW REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf
Oracle 19364 Oracle 26u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf
Oracle 19368 Oracle 20u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf
Oracle 19374 Oracle 24u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf
Oracle 19383 Oracle 19u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf
You can see that there are dbw0 processes.
3. Create a table in the example tablespace and insert data, and manually run the checkpoint process to ensure that Dbw0 writes to the file.
Sys@orcl>create table test_a (x int) Tablespace example;
Table created.
Sys@orcl>insert into test_a Select rownum from dual connect by rownum<=10000;
10000 rows created.
sys@orcl>commit;
Commit complete.
Sys@orcl>alter system checkpoint;
System altered.
4. Remove EXAMPLE01.DBF from the operating system at this time
[Oracle@oracle orcl]$ ls
AAA01.DBF control03.ctl redo02.log system01.dbf undotbs01.dbf
Control01.ctl example01.dbf redo03.log temp01.dbf users01.dbf
Control02.ctl redo01.log sysaux01.dbf ts_catalog01.dbf users02.dbf
[Oracle@oracle orcl]$ RM example01.dbf
Now let's take a look at the process of locking example01.dbf.
[Root@oracle ~]# lsof |grep Example
Oracle 19362 Oracle 23uW REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
Oracle 19364 Oracle 26u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
Oracle 19366 Oracle 24u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
Oracle 19368 Oracle 20u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
Oracle 19374 Oracle 24u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
Oracle 19383 Oracle 19u REG 253,0 104865792 918426/u01/app/oracle/oradata/orcl/example01.dbf (delet Ed
There are still 19362 instructions at this point dbw0 still lock the file
5. At this time, empty the contents of the Buffer_cache, and then query the data in the example table, insert data
Sys@orcl>alter system flush Buffer_cache;
System altered.
Sys@orcl>select Count (*) from test_a;
COUNT (*)
----------
10000
Read succeeded
Inserting data
Sys@orcl>insert into test_a values (5);
1 row created.
sys@orcl>commit;
Commit complete.