Kamran Agayev's Oracle Blog

Oracle Certified Master

RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

Posted by Kamran Agayev A. on March 4th, 2012

During a Disaster Recovery check, I got an error while restoring SPFILE from autobackup:

[php]RMAN> restore spfile to ‘/tmp/spfile.ora’ from ‘/rman_backup/control_autobackup_8357269245-20120303-00.bkp;

<em>RMAN-00571: ===========================================================</em>
<em>RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============</em>
<em>RMAN-00571: ===========================================================</em>
<em>RMAN-03002: failure of restore command at 03/03/2011 18:06:11</em>
<em>RMAN-06172: no autobackup found or specified handle is not a valid copy or piece[/php]

 

I’ve checked all available solutions that I know, but unable to restore it.

I started to confuse if it’s not a backup of the current database, so I used strings command and checked the database name inside the controlfile

[php][oracle @db] strings /rman_backup/control_autobackup_8357269245-20120303-00.bkp | grep prod

PROD[/php]

 

Prod is the name of my database, so this is the correct autobackup.

I’ve automated the RMAN backup and wrote a shell script which copies newly created backup files to the remote FTP host. I’ve copied the controlfile autobackup  from the FTP host to the test machine for the Disaster Recovery. Suddenly I remembered the mode that’s used to copy the backup files via FTP. It’s NOT binary! I’ve checked the size of controlfile that’s in FTP server with the one which is located at the production database. There were different! So it’s really “not a valid copy or piece” as RMAN states.

I’ve added FTP command – “binary”  to the shell script to switch to the binary mode, run the backup script again and got my backups copied to the FTP server. Then I tried to restore spfile from the backup and of course – succeeded.

So if copy RMAN backups to the FTP server, make sure you’re using binary mode and don’t forget to perform a Disaster Recovery to make sure your backups are valid

Posted in Administration | 8 Comments »

Exclusive Interview with Kai Yu

Posted by Kamran Agayev A. on February 16th, 2012

Kai Yu is a senior engineer and solution architect in Dell Oracle Solutions Engineering Lab  .He has worked with Oracle Technology as an Oracle DBA, Oracle Apps DBA since 1995 and is specializing in Oracle RAC, Oracle E-Business Suite and Oracle VM.  Kai has published 16 technical whitepapers  and given more than 40 technical presentations at major oracle technology conferences worldwide including Oracle OpenWorld, UKOUG, Collaborates, OTN Latin America/APAC Tours, etc. Kai is an Oracle ACE Director and was selected for Oracle ACE spotlight in June 2011, and also was featured  in Oracle Magazine Sept/Oct 2010 issue. Kai has been the president and is the current board member of IOUG Oracle RAC SIG and co-founder and board member of  IOUG Virtualization SIG.  Kai was the winner of  the 2011 OAUG Innovator of Year award . Kai has been active in sharing his Oracle knowledge on his Oracle blog http://kyuoracleblog.wordpress.com/.

Could u please provide answer to the following questions as follows:

  • Brief information about yourself and your family

I work for Dell Oracle Solutions Engineering lab. I was originally from China. I live in Austin, Texas, USA with my wife Jin who also works in software industry, and my daughter Jessica who currently is a freshman in high school.

 

  • Your education:

I got my BS and MS degree in Computer science in China before I came to US. Then I got my second MS in Computer Science in US.

 

  • Your experience with Oracle. When you started first? Has it been interest of your side or just a coincidence?

        My interest with database started with my Mater degree thesis research on relational database more    than 20 years ago. My Oracle database career started in 1995 shortly after when I took a database engineer position in a software company working on OCI and C++, PL/SQL and DBA. On that job, I really enjoyed learning and working on Oracle database technology on both applications development side as well as the database administration side. The technology really fascinated me and I decided to pursue my career in Oracle database.

  • What was the motive behind to prefer Oracle? Who you have been influenced by?

  I was motivated by the great flexibility and power of the Oracle database and the strong technology behind it.  In my career with Oracle Technology, I have been really inspired by several people. My first mentor was the chief database architect Chip Young in my early career who taught me how to build a high performance application on Oracle Database. In 1997 I learned the Oracle Parallel server (OPS) technology from an Oracle parallel server architect from Oracle and started working  with Oracle cluster database technology. Since 2006, Nadia Bendjedou and Steven Chan and Erik Peterson at Oracle really inspired me to take my Oracle Technology career to the next level by contributing my efforts to the Oracle community (user groups) and Oracle conferences.  With their great inspiration, in April 2010 I reached a great highlight in my career when I was awarded the Oracle ACE Director rank by Oracle Technology Network

 

  • What would your preference of profession if not Oracle?

I would probably end up in software development work.

  • What motivates you in your job?

The appreciation and love of the technology always motivate me to learn and try new things in my job.

 

  • Do you give lectures on Oracle?

Not official Oracle University class. But I have done several seminars on Oracle RAC SIG, which were recorded and managed by Oracle University and are publically accessible. I also have spoken at several  IOUG web seminars and Oracle technology conferences worldwide such as Oracle OpenWorlds, IOUG/OAUG Collaborate conferences, UKOUG conference, Scotland conference, Ottawa  conference, OTN (Oracle Technology Network) Latin America conference tour and APAC conference tour.

 

  • Have you authored any book in Oracle?

I have not finished any book. Recently Syed Jaffar Hussain has been very kind to invite me to co-author his new Oracle RAC book with him

 

  • Do you manage with your time as to read books on Oracle? What is the name of the book that you read recently?

By working in an engineering lab, I usually work on very latest technology on which normally there are no many published books around. I spent more time reading Oracle documents, whitepapers, Oracle support notes and Oracle blogs of other colleagues and OTN forms. But I do find a great value to read various published Oracle books to learn the topics in details in a systematic ways.

Here is a list of books I found very useful:

  1.        Oracle Database 11g Release 2 High Availability: Maximize Your Availability with Grid Infrastructure, RAC and Data Guard by  Scott Jesse, Bill Burton, Bryan Vongray
  2.        Oracle Backup & Recovery: Expert secrets for using RMAN and Data Pump, Kamran Agayev Agamehdi & Aman Sharma
  3.        Oracle 11g R1/R2 Real Application Clusters Essentials , by Ben Prusinski, Syed Jaffer Hussain
  4.        Oracle Wait Interface: A Practical Guide to Performance Diagnostics & Tuning  by Richmond Shee, Kirtikumar Deshpande and K. Gopalakrishnan
  5.        For Oracle Applications DBA, Oracle Applications DBA Field Guild  by  Elke Phelps, Paul Jackson     

  • What do you think on OTN forums?

Oracle Technology forums is really a great way for people to share the experience and help each other. A lot of time when I ran into issues, I was able to find some hints or even the answers to my problem. I also try to share my findings on the OTN whenever possible. 

  • Do you refer to the documentation? And how often does it happen?

I would say Oracle documentation is my primary resource to learn the new products. Many times I started with the beta version of the product as well as the beta version of the documentations. Last year when I involved  Oracle Enterprise Manager cloud control 12c beta and Oracle VM 3.0 beta, I have heavily relied on the beta documentations and the consultation of  the Oracle product managers, even the engineers from the development team.

 

  • What is the biggest mistake you have ever made during your DBA career?

Back to the late 90’s, on the third day after I just started working for a small company, the rented small data center had  some issue with its air conditioning, and I didn’t pay much attention and only forwarded the issue to the data center facility manager to fix it. But the fix was not done immediately. Next day, the database crashed, and I was not able to bring up the database as the database startup always crashed in middle of the instance recovery. After working with Oracle support, the root cause was identified that the data block corruption in the logs caused by the overheated storage pretended the instance recovery from completing. So we had to fix the storage issue and restored the database from the backup and recovered the database to the time right before this corrupted block was written. It was very painful and very time consuming process to get the main revenue generating database back online. Luckily I implemented the online database backup in the very first day when I joined the company.

  

  • What was your greatest achievement as an Oracle DBA?

In my 17 years Oracle DBA ad architect career, I have received many awards including three times awards from Dell Executive management, and the 2011 OAUG innovator of year award from OAUG.  But my greatest achievements were that I was able to catch up the latest technology and to be recognized by Oracle technology community with the Oracle ACE director rank and the privilege to get to know many industry leading experts in various areas of Oracle Technology.  

  • What is you priority to manage the challenges you face?

My priority is always the technology. My job requires me to research the technology and design and implement the Oracle engineering solutions for various IT organizations.

  

  • How would you describe the essence of your success? According to your definition of success, how successful have you been so far?

Hard working, appreciation and interest on technology are the essence of my success. I am pretty happy for what I am doing today.

 

  • What are your best skills which make you differ from others?

I got a chance to work on the entire IT stack: server, storage, networking, virtualization, OS,  database, middleware, and applications. This allows me to look at the problems from a broad view

  • What’s your major weakness?

I prefer hand on technology work,  not much management type work.

 

  • Have you ever lost your spirit? If so, what has been the reason and how have you overcome it?

Not really. But I found hard time working with the people that don’t appreciate technology and don’t appreciate technical skills.

  • What is the next success you would like to attain and your efforts to this end?

 I would appreciate if I can get a higher technology ladder like a principle architect position or a technical director position as I have been in my current senior technical position for ten years. But I will continue to focus on my technology interest no matter what.

 

  • How do you balance your daily life with your career?

It has been a very challenge to balance my daily life and my career, as I like them both, but there is no enough time. But it may be possible to have both sometime. Last year, I took my daughter with me on my conference trip to England and Scotland, and she found it very interesting and very educational on the trip.

 

  • Please describe your one day summary of activities?

I normally get up around 7:30am, taking my daughter to school and get into office around 9:00am. I work in office until 7:00pm. And after dinner, I started working around 8:30pm to 12:30am.  During the night hours, I may also talk to my daughter for her school work or watch some piece of movies or TV on a break.

  • How many hours do you work and sleep in a day?

Around 6 hours a day, and depending on the workload or other activities.

  • Where and how do you spend your daily, weekly and annual holidays?

I like to spend my holiday in travel around the world, also visiting my parents and brother and sister in China.

  • Do you think about Oracle during vacations?

No much, travel is my big favor. I would like to learn the different cultures and places on travel. I also travel to different places in the world for Oracle conferences as well as for vacations.

 

  • Do you have time or motivation to go in for any sports? If yes, which kind of sport do you go in for?

I swim and play Ping-Pong (table tennis) and also run sometime.

 

  • What’s your favorite meal and non-alcoholic drink?

I don’t have any particular favorite food, but just prefer light taste food, not much non-alcoholic drink either.

  • What foreign languages do you know?

Beside of English, I speak standard Chinese, my native language.

  • What’s your average typing speed?

I can’t type very fast, as never had any special training on typing

  • Have you ever get involved in politics?

No. Not very interested.

  • What are your hobbies? 

Swimming, playing Ping-Pong, military/history.

 

  • How do you spend your free time?

Being with family, travelling, exercising, reading, watching  movies/TVs, house work etc. 

  • What’s your biggest ambition?

Visiting all the countries in the world.

  • What would be your advice to the beginners in Oracle?

          Learn the solid foundation of the major; Have a strong passion for the Oracle technology;  be ready for the life time learning.

  • Would you like your children to follow in your footsteps or take a different path in life?

That will depend on her interest. I don’t force anything. However, I see technology is a very good career.

  • Do you have any followers of you?

I have seen some followers in my blogs. But I found that people are easier to find the materials from my blog entries than from my whitepapers and conferences although my 16 whitepapers and more than 40 conferences presentations listed in my Oracle blog (http://kyuoracleblog.wordpress.com) have much richer materials than those on my blog entries. I plan to find some time to extract some materials from those whitepapers and conference presentations and put them on some the blog entries so that the search engine can pick up them.

 

  • What is your vision on the future of Oracle?

I think Oracle is a great company that produces the great Oracle Technology. I love to continue to work with Oracle Technology.

 

  • Could you please take a photo in your office near to your desktop?

Posted in Expert Interviews | 3 Comments »

Getting “ORA-00959: tablespace ‘TBS01’ does not exist” during Data Pump import

Posted by Kamran Agayev A. on February 14th, 2012

When importing data from different database, sometimes you get errors like:

[php]

ORA-39083: Object type TABLESPACE_QUOTA failed to create with error:
ORA-00959: tablespace ‘TBS01’ does not exist
Failing sql is:

[/php]

This means that the tablespace “TBS01” doesn’t exist in the database where you’re importing the data. For this, you can use REMAP_TABLESPACE option. If you have more than one tablespace that doesn’t exist in the second database, use comma as follows:

[php]REMAP_TABLESPACE=db01_tbs01:db02_tbs,db_01_tbs02:db02_tbs [/php]

 

To get which remap script you need to create, check TABLESPACE_NAME column for the DBA_SEGMENTS view and find in which tablespaces your objects are reside

Posted in Administration | 4 Comments »

NOT IN with NULL values

Posted by Kamran Agayev A. on February 13th, 2012

I strongly believe that you already know that NOT IN doesn’t take NULL values into account and those values are not displayed in the output

Check the following example:

[php]SQL> create table my_table (id number, name varchar2(10));

Table created.

SQL> insert into my_table values(1,’test1′);

1 row created.

SQL> insert into my_table values(2,null);

1 row created.

SQL> insert into my_table values(3,’test2′);

1 row created.

SQL> commit;

Commit complete.

SQL>
SQL>
SQL> select * from my_table;

ID NAME
———- ———-
1 test1
2
3 test2

SQL> select * from my_table where name not in (‘test2’);

ID NAME
———- ———-
1 test1

SQL>[/php]

 

For more information check the following links:

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:442029737684

http://jonathanlewis.wordpress.com/2007/02/25/not-in/

Posted in Administration | No Comments »

Regsiter for BIG Data online Forum

Posted by Kamran Agayev A. on February 5th, 2012

There will be an online forum with interesting sessions on BIG Data at February 16th. If you’re interested on Big Data, don’t miss it. Here’s the registration link:

https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&eventid=388878&sessionid=1&key=4FEDBC21F62A9834AAE0B109EBBFC918&partnerref=exadata_email1_Jan_Bigdata&sourcepage=register

 

Posted in Uncategorized | No Comments »

Login operation failed in Grid Control

Posted by Kamran Agayev A. on February 1st, 2012

Today, when I was trying to connect to the OEM Grid Control, I got “Login operation failed” error

The first file to be checked are the log and trace files at  Grid side. So I checked emoms.trc and emoms.log files under $OMS_HOME/sysman/log and didn’t find anything. I checked the repository database, it was up and running. After a while I realized that it’s a connection problem and checked $OMS_HOME/sysman/config/emoms.properties file and saw that it is trying to connect to the 2222 port  as a Repository Connection:

[php]oracle.sysman.eml.mntr.emdRepConnectDescriptor=(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=host03)(PORT\=2222)))( CONNECT_DATA\=(SID\=oemgrid)))[/php]

When I checked listener at the repository side, I saw that it wasn’t configured to accept connections from port 2222

I added the above port number to the non-default connection section at listener.ora file and started the listener

[php]second_listener =

(DESCRIPTION=

(ADDRESS_LIST=

(ADDRESS=(PROTOCOL=tcp)(HOST=host3)(PORT=2222))))

SID_LIST_second_listener =

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=oemgrid)

(ORACLE_HOME=/u01/oracle/product/10.2.0/db_1)

(SID_NAME=oemgrid)))

-bash-3.2$ lsnrctl  start second_listener
Listener Log File         /u01/oracle/product/10.2.0/db_1/network/log/second_listener.log
Listening Endpoints Summary…  
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host3)(PORT=2222)))
Services Summary…
Service "oemgrid" has 1 instance(s).  
Instance "oemgrid", status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully

[/php]

I tried to connect to the Grid Control again, and succeeded. So if you got “Login operation failed” error and didn’t get any information from the Grid Control log files, the listener and port issues can be the reason

Posted in Administration | No Comments »

Finding the folder that consumes more space in Linux OS

Posted by Kamran Agayev A. on January 23rd, 2012

Sometimes we got some folders filled with unknown files either due to any bug where Oracle creates 100 files in a second :) or due to the OS bugs. And in some cases we’re not able to find in which folder files were created. For that, you can use the simplest command in Linux to get the output for the folders with its size sorted. Here’s the command:

[php]du -s /u01/* | sort -n -r

…….

28G     /u01/oracle/product/10.2.0/db_1/flash_recovery_area

……..[/php]

 

From the output you will get the folder which consumes more space

Posted in Administration, Oracle on Linux | 4 Comments »

My presentation at Oracle OpenWorld 2011 – San Francisco

Posted by Kamran Agayev A. on January 12th, 2012

I’m getting a lot of emails from readers asking me to share my OpenWorld 2011 presentation files. So I decided to share it with you. Here, you can download the presentation with necessary video tutorials that I’ve shown at OpenWorld 2011. Download the .zip file and extract it under the folder C:\ and make sure you run the presentation from the following folder –c:\OOW 2011 – Kamran Agayev A\

Downloaded 3272 times

I’ve also uploaded a part of my speech to youtube, you can watch it online:

httpv://www.youtube.com/watch?v=5RPUxotUk9A&hl=en&fs=1&border=1

Posted in Uncategorized | 3 Comments »

Oracle Flashback Technologies – VIDEO Tutorial

Posted by Kamran Agayev A. on January 6th, 2012

In this video tutorial I show practical demonstrations on all Flashback Technologies that are avaiable in Oracle

 

To download the .mp4 format of the video tutorial, use the following link:

http://www.kamranagayev.com/Video_Tutorials/Flashback_Technologies.mp4

Posted in Administration | 11 Comments »

Dumping an Oracle data block, reading the output and doing some math

Posted by Kamran Agayev A. on October 31st, 2011

In this post I’d like to show you how to dump a smallest logical structure of an Oracle Database – Data Block. Have you ever interested what’s actually stored in the data block and if it’s possible to get any information by “dumping” it? Sure you have. You can dump a single data block of the datafile. Let me show you how it’s done

First of all let’s create a new tablespace and a table:

[php]SQL> create tablespace my_tbs datafile ‘/u01/oracle/oradata/repdb/my_tbs.dbf’ size 100m;

Tablespace created.

SQL> create table my_tab tablespace my_tbs as select * from dba_objects;

Table created.[/php]

Now let’s get more information about this table from DBA_SEGMENTS view:

[php]SQL> select header_file, header_block, bytes, blocks, extents from dba_segments where segment_name=’MY_TAB’;

HEADER_FILE HEADER_BLOCK BYTES BLOCKS EXTENTS
———– ———— ———- ———- ———-
7 9 7340032 896 22

SQL> [/php]

From the output we can say that the header block of the table is stored in the datafile 7, block 9. The size of the table 7340032 bytes (7.3 Mb) and it contains 896 blocks and 22 extents. After getting block size of the database, let’s do some math:

[php]SQL> show parameter db_block_size

NAME TYPE VALUE
———————————— ———– ——————————
db_block_size integer 8192
SQL>
[/php]

BLOCKS (dba_segments) * DB_BLOCK_SIZE (parameter file) = BYTES (dba_segments)

896*8192=7340032

Now let’s query DBA_EXTENTS view to get some information on extents and data blocks of this table:

[php]SQL> col segment_name format a10
SQL> set pagesize 100
SQL> select segment_name, extent_id, block_id, blocks, bytes from dba_extents where segment_name=’MY_TAB’;

SEGMENT_NA EXTENT_ID BLOCK_ID BLOCKS BYTES
———- ———- ———- ———- ———-
MY_TAB 0 9 8 65536
MY_TAB 1 17 8 65536
MY_TAB 2 25 8 65536
MY_TAB 3 33 8 65536
MY_TAB 4 41 8 65536
MY_TAB 5 49 8 65536
MY_TAB 6 57 8 65536
MY_TAB 7 65 8 65536
MY_TAB 8 73 8 65536
MY_TAB 9 81 8 65536
MY_TAB 10 89 8 65536
MY_TAB 11 97 8 65536
MY_TAB 12 105 8 65536
MY_TAB 13 113 8 65536
MY_TAB 14 121 8 65536
MY_TAB 15 129 8 65536
MY_TAB 16 137 128 1048576
MY_TAB 17 265 128 1048576
MY_TAB 18 393 128 1048576
MY_TAB 19 521 128 1048576
MY_TAB 20 649 128 1048576
MY_TAB 21 777 128 1048576
[/php]

Using DBA_EXTENTS view we can get BLOCK_ID range and number of data blocks in each extent. Look at the following output:

[php]MY_TAB 0 9 8 65536
MY_TAB 1 17 8 65536[/php]

Here it’s seen that the first extent (0) contains 8 blocks which id range between 9 and 17
9 (block_id) + 8 (number of blocks) = 17 (block_id of the next extent)

Ok, now let’s start dumping the header block of the table. For this we need data file and header block number. It can be taken from the DBA_SEGMENTS

[php]SQL> select header_file, header_block from dba_segments where segment_name=’MY_TAB’;

HEADER_FILE HEADER_BLOCK
———– ————
7 9

SQL> [/php]

The dump file will be stored in UDUMP directory (user_dump_dest). We can use TRACEFILE_IDENTIFIER to specify part of the trace file name and find it quickly under the UDUMP directory.

[php]SQL> alter session set tracefile_identifier = db_block_dump;

Session altered.[/php]

Now, dump the data block 9 of the datafile 7:

[php]SQL> alter system dump datafile 7 block 9;

System altered.

SQL> [/php]

Ok, now open the second session (in new terminal) and open the trace file. You will see the following output:

[php]tail -f repdb_ora_18308_DB_BLOCK_DUMP.trc

*** 2011-10-28 17:05:21.015
Start dump data blocks tsn: 7 file#: 7 minblk 9 maxblk 9
buffer tsn: 7 rdba: 0x01c00009 (7/9)
scn: 0x0000.02eeaf02 seq: 0x01 flg: 0x04 tail: 0xaf021001
frmt: 0x02 chkval: 0x1a9f type: 0x10=DATA SEGMENT HEADER – UNLIMITED
Extent Control Header
—————————————————————–
Extent Header:: spare1: 0 spare2: 0 #extents: 22 #blocks: 895
last map 0x00000000 #maps: 0 offset: 4128
Highwater:: 0x01c0037a ext#: 21 blk#: 113 ext size: 128
#blocks in seg. hdr’s freelists: 0
#blocks below: 880
mapblk 0x00000000 offset: 21
Unlocked
Map Header:: next 0x00000000 #extents: 22 obj#: 130752 flag: 0x40000000
Extent Map
[/php]

Let’s try to read the above output :

* Start dump data blocks tsn: 7 file#: 7 minblk 9 maxblk 9
This means that the following lines is the output of datafile 7, block 9. Range of blocks can be given to dump:
[php]alter system dump datafile 1 block min 29081 block max 30539 [/php]

* rdba is the Data Block Address which is internal representation of the block address. The first 10 bits contains file number, and the rest 22 bits contains block id. So here if we convert 0x01c00009 to decimal, we would get 7/9 which is shown between brackets. Moreover, DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE and DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK can be used to get the file and block number based on RDA value. But before using these functions, rda should be converted to the decimal value.
So here, we convert the rda value (0x01c00009) to decimal and got – 29360137. Then pass this value to the above mentioned functions:

[php]SQL> select DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(29360137) from dual;

DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(29360137)
———————————————-
7

SQL> select DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(29360137) from dual;

DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(29360137)
———————————————–
9

SQL> [/php]

In order to convert hexadecimal value to the decimal online, you can use the following link:
http://www.statman.info/conversions/hexadecimal.html

By using DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS function and passing file and block value, we can get RDA value:

[php]SQL> select DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(7,9) from dual;

DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(7,9)
—————————————–
29360137

SQL>
[/php]

* scn – is the SCN value of the block which defines when it was last modified. We can compare it with each transaction SCN value inside the dump file. The SCN value of the data block is 0x0000.02eeaf02. If second part of this value (02eeaf02) is converted to the decimal, then we got – 49196802. If we query the current_scn value we got:

[php]SQL> select current_scn from v$database;

CURRENT_SCN
———–
49249322

SQL> [/php]

* tail is used to keep track of consistency information between the beginning and end of the block against the possibility of distribution of oracle blocks over multiple OS blocks

* frmt – is the block format which tells whether it’s Oracle 7 or Oracle 8 and higher block. 0x02 represents that it’s Oracle 8 and higher block. (0x01 represents that it’s Oracle 7 block)

* chkval – which is checksum written to the blocks when it is set and used by Oracle in part to check the consistency and validity of the block

* type : Type defines which type of block it is. In this example it is “Data Segment Header”

[php] Extent Header:: spare1: 0 spare2: 0 #extents: 22 #blocks: 895 [/php]

Then in the Extent Control Header part we can get information about extents. So it has 22 extents and 895 blocks.

[php] Highwater:: 0x01c0037a ext#: 21 blk#: 113 ext size: 128
#blocks in seg. hdr’s freelists: 0
#blocks below: 880 [/php]

Highwater mark is at extent 21, block 113. This extent has 128 blocks. And there’re 880 data block below it. Let’s do some math:

As it has 880 blocks below and the number of block is 895 (dump file didn’t count the header block), then there’re 895-880=15 data blocks free (and above the hightwater mark)
Moreover, as the highwater mark is at block 113 and the extent has 128 data blocks, then 128-113=15 data blocks are free
So this means that there’s 15*8192=122880 bytes (122Kb) free space

[php] Map Header:: next 0x00000000 #extents: 22 obj#: 130752 flag: 0x40000000[/php]

Next, we got object id. To find more details on that object, query sys.obj# view:

[php]SQL> col name format a10
SQL> select obj#, owner#, name, status, ctime, type# from sys.obj$ where obj#=130752;

OBJ# OWNER# NAME STATUS CTIME TYPE#
———- ———- ———- ———- ——— ———-
130752 0 MY_TAB 1 28-OCT-11 2

SQL> [/php]

So the owner id is 0 (which is SYS user) and type is 2 (which means table)

[php]SQL> select username from dba_users where user_id=0;

USERNAME
——————————
SYS

SQL> [/php]

and to get information about types, use the following query:

[php]select USERNAME,

count(decode(o.TYPE#, 2,o.OBJ#,”)) Tabs,

count(decode(o.TYPE#, 1,o.OBJ#,”)) Inds,

count(decode(o.TYPE#, 5,o.OBJ#,”)) Syns,

count(decode(o.TYPE#, 4,o.OBJ#,”)) Views,

count(decode(o.TYPE#, 6,o.OBJ#,”)) Seqs,

count(decode(o.TYPE#, 7,o.OBJ#,”)) Procs,

count(decode(o.TYPE#, 8,o.OBJ#,”)) Funcs,

count(decode(o.TYPE#, 9,o.OBJ#,”)) Pkgs,

count(decode(o.TYPE#,12,o.OBJ#,”)) Trigs,

count(decode(o.TYPE#,10,o.OBJ#,”)) Deps

from obj$ o,

dba_users u

where u.USER_ID = o.OWNER# (+)

group by USERNAME

order by USERNAME
[/php]

In order to show the free space, we can use DBMS_SPACE.UNUSED_SPACE procedure. Let’s create a procedure :

[php]SQL> create or replace
2 procedure show_space
3 ( p_segname in varchar2,
4 p_owner in varchar2 default user,
5 p_type in varchar2 default ‘TABLE’,
6 p_partition in varchar2 default NULL )
7 authid current_user
8 as
9 l_free_blks number;
10 l_total_blocks number;
11 l_total_bytes number;
12 l_unused_blocks number;
13 l_unused_bytes number;
14 l_LastUsedExtFileId number;
15 l_LastUsedExtBlockId number;
16 l_LAST_USED_BLOCK number;
17
18 procedure p( p_label in varchar2, p_num in number )
19 is
20 begin
21 dbms_output.put_line( rpad(p_label,40,’.’) ||
22 p_num );
23 end;
24
25 begin
26 dbms_space.unused_space
27 ( segment_owner => p_owner,
28 segment_name => p_segname,
29 segment_type => p_type,
30 partition_name => p_partition,
31 total_blocks => l_total_blocks,
32 total_bytes => l_total_bytes,
33 unused_blocks => l_unused_blocks,
34 unused_bytes => l_unused_bytes,
35 LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
36 LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
37 LAST_USED_BLOCK => l_LAST_USED_BLOCK );
38
39 p( ‘Total Blocks’, l_total_blocks );
40 p( ‘Total Bytes’, l_total_bytes );
41 p( ‘Total MBytes’, trunc(l_total_bytes/1024/1024) );
42 p( ‘Unused Blocks’, l_unused_blocks );
43 p( ‘Unused Bytes’, l_unused_bytes );
44 p( ‘Last Used Ext FileId’, l_LastUsedExtFileId );
45 p( ‘Last Used Ext BlockId’, l_LastUsedExtBlockId );
46 p( ‘Last Used Block’, l_LAST_USED_BLOCK );
47 end;
48
49 /

Procedure created.

SQL> set serveroutput on
SQL> exec show_space(‘MY_TAB’,’SYS’);
Total Blocks……………………….896
Total Bytes………………………..7340032
Total MBytes……………………….7
Unused Blocks………………………15
Unused Bytes……………………….122880
Last Used Ext FileId………………..7
Last Used Ext BlockId……………….777
Last Used Block…………………….113

PL/SQL procedure successfully completed.

SQL> [/php]

Now I copy/paste the math I’ve done above again to compare both results.

As it has 880 blocks below and the number of block is 895 (dump file didn’t count the header block), then there’re 895-880=15 data blocks free (and above the hightwater mark)
Moreover, as the highwater mark is at block 113 and the extent has 128 data blocks, then 128-113=15 data blocks are free
So this means that there’s 15*8192=122880 bytes (122Kb) free space

As you see comparison of both values led us to the same results

So in this post you’ve learned how to dump a header block of the segment and how to read it. In the next post I’ll try to go more deep and dump a data block that contains data, make some transactional changes on the data and see what happens in the background in the block level!

Posted in Uncategorized | 8 Comments »