Friday, May 11, 2012

Which datafile contains my table??


SQL> connect syed/syed
Connected.
SQL> create table t1(c1 number, c2 varchar2(200));

Table created.

SQL> begin
  2  for i in 1..2400
  3  loop
  4  insert into t1 values(i,'test data');
  5  end loop;
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> /

PL/SQL procedure successfully completed.

SQL> /

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL>connect / as sysdba

SQL>select e.segment_name,e.partition_name,e.segment_type,d.file_name
from dba_extents e,dba_data_files d
where (e.file_id,e.block_id) in (select file_id,max(block_id) from dba_extents where
segment_name='T1' group by file_id)
 and e.file_id=d.file_id
and e.owner='SYED'
and e.segment_name='T1' ;

SQL>SEGMENT_NA SEGMENT_TYPE       FILE_NAME
---------- ------------------ --------------------------------------------------
T1         TABLE              /u01/app/oracle/oradata/disk3/db1/users02.dbf
T1         TABLE              /u01/app/oracle/oradata/disk3/db1/users01.dbf

No comments:

Post a Comment