日期:2014-05-16  浏览次数:20556 次

从视图获得asm 信息。

 今天是2014-03-10,堕落了半个月了,继续回到学习的脚本上来。加油!

 1、当使用asm管理database file,那么在 创建表空间的时候会自动按照默认参数位置进行文件创建,且默认大小 为100MB;

默认创建位置主要受:db_create_file_dest影响:

SQL> show parameter db_create_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      +DATAGROUP1
SQL> 

查看数据文件和区间对应关系:

内部视图x$kffxp介绍:
x$KFFXP column name     meaning
ADD              Address
indx                    row index
inst_id                 instance identifier(1 for single instance,1..n for RAC)
group_kffxp             disk group number;corresponds to v$asm_diskgroup.group_number
number_kffxp            file number,corresponds to v$asm_file.file_number
compound_kffxp      compound index; corresponds to v$asm_file.compound_index
incarn_kffxp      incarnation;corresponds to v$asm_file.incarnation
pxn_kffxp               physical extent number extent number per file
xnum_kffxp               extent number
lxn_kffxp               logical extent number(0=primary,1=mirrored copy)
disk_kffxp              disk number;corresponds to v$asm_disk.disk_number
au_kffxp                offset within the device in multiples of the allocation unit size (v$asm_diskgroup.allocation_unit_size)
flags_kffxp            
SIZE_KFFXP          size_kffxp is used such that we account for variable sized extents.
sum(size_kffxp)          provides the number of AUs that are on that disk.

eg:

set linesize 200 pagesize 200000
col path for a60
col name for a40
select dg.name,
       x.NUMBER_KFFXP "FILE NUMBER",
       x.XNUM_KFFXP "EXTENT NUMBER",
       decode(x.LXN_KFFXP, 0, 'P', 1, 'M', 'MM') "EXTENT TYPE",
       d.path
  from x$kffxp x, v$asm_disk d, v$asm_diskgroup dg
 where x.GROUP_KFFXP = d.GROUP_NUMBER
   and x.DISK_KFFXP = d.DISK_NUMBER
   and x.GROUP_KFFXP = dg.GROUP_NUMBER
   and x.NUMBER_KFFXP in
       (select file_number from v$asm_alias where name like '%TENGFANG%')
 order by x.NUMBER_KFFXP, x.XNUM_KFFXP, x.LXN_KFFXP;

 

select a.name        fname,
       a.file_number fnum,
       b.xnum_kffxp  extnum,
       b.lxn_kffxp   lognum,
       b.disk_kffxp  dnum,
       b.au_kffxp
  from v$asm_alias a, x$kffxp b
 where a.group_number = b.group_kffxp
   and a.file_number = b.n