24.Which two statements correctly describe the relation between a data file and the logical database

来源:互联网 发布:今日财经数据 编辑:程序博客网 时间:2024/05/23 23:48
24.Which two statements correctly describe the relation between a data file and the logical database
structures? (Choose two.)
A.An extent cannot spread across data files.
B.A segment cannot spread across data files.
C.A data file can belong to only one tablespace.
D.A data file can have only one segment created in it.
E.A data block can spread across multiple data files as it can consist of multiple operating system (OS) 
blocks.
答案:AC
解析:

参考:http://docs.oracle.com/cd/E11882_01/server.112/e40540/logical.htm#CNCPT303


SQL> l
  1  select a.FILE_NAME,count(*) from dba_data_files a,dba_segments b
  2  where a.TABLESPACE_NAME=b.tablespace_name and a.tablespace_name='USERS'
  3* group by a.file_name
SQL> /


FILE_NAME                                  COUNT(*)
---------------------------------------- ----------
/u01/oracle/oradata/wahaha3/users01.dbf          43
一个数据文件有43个segment,排除D
一个数据文件可以包括多个segment,一个segment可以有多个extent,一个extent可以有多个oracle block,一个block可以有多个os block,排除E
下面这句,说明A正确
By default, the database allocates an initial extent for a data segment when the segment is created. An extent is always contained in one data file.

Although no data has been added to the segment, the data blocks in the initial extent are reserved for this segment exclusively. 

--这里验证一下B
SQL> create  tablespace tt datafile '/home/oracle/tt.dbf' size 2m;


Tablespace created.


SQL> create table ts (a char(1000)) tablespace tt;


Table created.


SQL> begin 
  2  for i in 1..10000 loop
  3  insert into ts values(i);
  4  commit;
  5  end loop;
  6  end;
  7  /
begin
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.TS by 128 in tablespace TT
ORA-06512: at line 3

SQL> select count(*) from ts;

  COUNT(*)
----------
       826

SQL> alter tablespace tt add datafile '/home/oracle/tt01.dbf' size 2m;

Tablespace altered.

SQL> begin
  2  for i in 1..10000 loop
  3  insert into ts values(i);
  4  commit;
  5  end loop;
  6  end;
  7  /
begin
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.TS by 128 in tablespace TT
ORA-06512: at line 3

SQL> select count(*) from ts;

  COUNT(*)
----------
      1708
SQL> select segment_name from dba_segments where tablespace_name='TT'
  2  ;

SEGMENT_NAME
--------------------------------------------------------------------------------
TS
--这里tt表空间只有一个segment,在第一个数据文件的时候,他是一个,在增加一个数据文件他还是一个,只不过空间增大了,因此B错误

0 0