左右v$datafile和v$tempfile中间file#

v$datafile关于存储在文件中的数据视图的信息,v$tempfile查看存储在一个临时文件中的信息。

有两种观点file#现场,首先来看看官方文件的定义:

V$DATAFILE

This view contains datafile information from the control file.

See Also:

"V$DATAFILE_HEADER", which displays information from datafile headers
ColumnDatatypeDescription
FILE#NUMBERFile identification number
CREATION_CHANGE#NUMBERChange number at which the datafile was created
CREATION_TIMEDATETimestamp of the datafile creation
TS#NUMBERTablespace number
RFILE#NUMBERTablespace relative datafile number
STATUSVARCHAR2(7)Type of file (system or user) and its status. Values: OFFLINEONLINESYSTEMRECOVERSYSOFF (an offline file from the SYSTEM tablespace)
ENABLEDVARCHAR2(10)Describes how accessible the file is from SQL:
  • DISABLED - No SQL access allowed

  • READ ONLY - No SQL updates allowed

  • READ WRITE - Full access allowed

  • UNKNOWN - should not occur unless the control file is corrupted

CHECKPOINT_CHANGE#NUMBERSCN at last checkpoint
CHECKPOINT_TIMEDATETimestamp of the checkpoint#
UNRECOVERABLE_CHANGE#NUMBERLast unrecoverable change number made to this datafile. If the database is in ARCHIVELOG mode, then this column is updated when an unrecoverable operation completes. If the database is not in ARCHIVELOG mode, this column does not get updated.
UNRECOVERABLE_TIMEDATETimestamp of the last unrecoverable change. This column is updated only if the database is in ARCHIVELOG mode.
LAST_CHANGE#NUMBERLast change number made to this datafile (null if the datafile is being changed)
LAST_TIMEDATETimestamp of the last change
OFFLINE_CHANGE#NUMBEROffline change number of the last offline range. This column is updated only when the datafile is brought online.
ONLINE_CHANGE#NUMBEROnline change number of the last offline range
ONLINE_TIMEDATEOnline timestamp of the last offline range
BYTESNUMBERCurrent datafile size (in bytes); 0 if inaccessible
BLOCKSNUMBERCurrent datafile size (in blocks); 0 if inaccessible
CREATE_BYTESNUMBERSize when created (in bytes)
BLOCK_SIZENUMBERBlock size of the datafile
NAMEVARCHAR2(513)Name of the datafile
PLUGGED_INNUMBERDescribes whether the tablespace is plugged in. The value is 1 if the tablespace is plugged in and has not been made read/write, 0 if not.
BLOCK1_OFFSETNUMBEROffset from the beginning of the file to where the Oracle generic information begins. The exact length of the file can be computed as follows:BYTES + BLOCK1_OFFSET.
AUX_NAMEVARCHAR2(513)Auxiliary name that has been set for this file via CONFIGURE AUXNAME
FIRST_NONLOGGED_SCNNUMBERFirst nonlogged SCN
FIRST_NONLOGGED_TIMEDATEFirst nonlogged time


V$TEMPFILE

This view displays tempfile information.

ColumnDatatypeDescription
FILE#NUMBERAbsolute file number
CREATION_CHANGE#NUMBERCreation System Change Number (SCN)
CREATION_TIMEDATECreation time
TS#NUMBERTablespace number
RFILE#NUMBERRelative file number in the tablespace
STATUSVARCHAR2(7)Status of the file (OFFLINE|ONLINE)
ENABLEDVARCHAR2(10)Enabled for read and/or write
BYTESNUMBERSize of the file in bytes (from the file header)
BLOCKSNUMBERSize of the file in blocks (from the file header)
CREATE_BYTESNUMBERCreation size of the file (in bytes)
BLOCK_SIZENUMBERBlock size for the file
NAMEVARCHAR2(513)Name of the file

从上面的文档能够看出。在v$tempfile和v$datafile中file#均代表绝对文件好,而rfile#代表相对文件号,以下来验证一下:

SQL> l
  1* select file#,name from v$tempfile
SQL> /

     FILE# NAME
---------- ------------------------------------------------------------
	 1 /home/app/oraten/oradata/oraten/temp01.dbf

SQL> select file#,name from v$datafile;

     FILE# NAME
---------- ------------------------------------------------------------
	 1 /home/app/oraten/oradata/oraten/system01.dbf
	 2 /home/app/oraten/oradata/oraten/undotbs01.dbf
	 3 /home/app/oraten/oradata/oraten/sysaux01.dbf
	 4 /home/app/oraten/oradata/oraten/users01.dbf
	 5 /home/app/oraten/oradata/oraten/test01.dbf
在v$datafile和v$tempfile中都存在绝对文件号为1的文件。这显然是不正确的。

我们知道在文件无法訪问时,oracle会报错并在错误信息中显示有关文件的信息,以下我们来模拟暂时文件的故障

[oraten@yue oraten]$ chmod 000 temp01.dbf 
[oraten@yue oraten]$ ll
总用量 932180
-rw-r----- 1 oraten dba   7061504 11月  7 13:59 control01.ctl
-rw-r----- 1 oraten dba   7061504 11月  7 13:59 control02.ctl
-rw-r----- 1 oraten dba   7061504 11月  7 13:59 control03.ctl
-rw-r----- 1 oraten dba  52429312 11月  7 13:44 redo01.log
-rw-r----- 1 oraten dba  52429312 11月  7 13:54 redo02.log
-rw-r----- 1 oraten dba  52429312 11月  7 13:44 redo03.log
-rw-r----- 1 oraten dba 272637952 11月  7 13:49 sysaux01.dbf
-rw-r----- 1 oraten dba 461381632 11月  7 13:49 system01.dbf
---------- 1 oraten dba  20979712 11月  7 13:39 temp01.dbf
-rw-r----- 1 oraten dba  10493952 11月  7 13:44 test01.dbf
-rw-r----- 1 oraten dba  26222592 11月  7 13:49 undotbs01.dbf
-rw-r----- 1 oraten dba   5251072 11月  7 13:44 users01.dbf

强制启动数据库

SQL> startup force
ORACLE instance started.

Total System Global Area  134217728 bytes
Fixed Size		    2094544 bytes
Variable Size		   88082992 bytes
Database Buffers	   37748736 bytes
Redo Buffers		    6291456 bytes
Database mounted.
Database opened.
SQL> 
创建暂时表。并插入数据

SQL> insert into t1 select * from user_tables;
insert into t1 select * from user_tables
            *
ERROR at line 1:
ORA-01157: cannot identify/lock data file 101 - see DBWR trace file
ORA-01110: data file 101: '/home/app/oraten/oradata/oraten/temp01.dbf'

呵呵,暂时文件无法訪问,在这里显示的文件号为101,为什么那?

我们将參数 db_files改动为200,继续实验

SQL> show parameter db_files

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_files			     integer	 100
SQL> alter system set db_files=200 scope=spfile;

System altered.

SQL> startup force
ORACLE instance started.

Total System Global Area  134217728 bytes
Fixed Size		    2094544 bytes
Variable Size		   88082992 bytes
Database Buffers	   37748736 bytes
Redo Buffers		    6291456 bytes
Database mounted.
Database opened.
SQL> insert into t1 select * from user_tables;
insert into t1 select * from user_tables
            *
ERROR at line 1:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/home/app/oraten/oradata/oraten/temp01.dbf'
原来,v$tempfile中的file#并非绝对文件号。暂时文件的绝对文件号是file#+db_files參数。

打完手工!






版权声明:本文博主原创文章。博客,未经同意不得转载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值