Skip to main content

Everything a DBA Need to Know About Oracle Data Block


<<Back to DB Administration Main Page

What is Oracle Database Block

An oracle data block (DB Block) is a logical unit of data storage. And is the smallest unit of IO for oracle database. The data is physically stored in datafiles (disk files) made up of operating system blocks (OS Blocks). The size of OS blocks can be different than the Oracle DB Block. The OS handles IO in OS blocks while oracle always reads, write data in multiple of DB blocks. The size of oracle DB block can be defined using DB_BLOCK_SIZE init parameter (default 8k ) at the time of database creation and can not be changed later.

You can configure multiple database block size in a database. To be specific you can define block size
for each tablespace (except SYSTEM, SYSAUX).

Oracle Data Block Structure

Now that you know what is oracle data block, Lets have a look how does it looks like. As you can see in the picture above the oracle DB block got a header (also known as block overhead) on top and data on bottom and  the free space lies in between . Database uses the header information to track the data and free space in the block.
An Oracle block overhead consists of header, table directory and row directory and oracle needs this information to manage the block itself.
Block header  => Block header holds general information about the block  eg address of the block on disk, segment type, Transaction information etc.
Table directory => This directory holds information like table metadata whose rows are stored in this block.
Row directory =>  In the form of row address, this holds the information to locate the rows in the block.
The block overhead totals between 84 to 107 bytes.
Like DB Block header every row in the block has its own header, we can call it row header. The row header of each row contains the information about the data stored in that particular row. Before going deep into Oracle DB Block lets have a look at Oracle ROW format as well.

Oracle Database ROW Format

Each row in a block is called row piece. Each row piece has a row header and column data as stated above.

Column Data => This hold the actual data in the row.
ROW Header => Row header contains information like
  • Number of columns in the row.
  • Information about chained and migrated rows.
  • Cluster key for table cluster (if applicable) etc.

Oracle database usages ROWID to uniquely identify a row in the database. The row id is not physically stored in the database, but computed using the file id and block id.
To know more about oracle ROW ID READ HERE

That's said lets get back to our original topic for this Blog ie Oracle Database Block,  And examine the facts little more in detail.  And to do so I have to dump a block and walk you through the dumpfile.
Steps to dump an oracle DB block is provided  HERE

Start dump data blocks tsn: 11 file#:64 minblk 132 maxblk 132
tsn: 11 => v$tablespace.TS#
file#:64 =>  v$datafile.FILE#
minblk & maxblk =>
dba_extents.BLOCK_ID (range of block ids dumped)
So from this line you can find the rage of blocks dumped (ie 132 to 132- just 1 block) from datafile#64 and Tablespace#11

Block dump from disk: <= self explanatory 

buffer tsn: 11 rdba: 0x10000084 (64/132)
buffer tsn: 11 => Tablespace Number
rdba 0x10000084 (64/132)  => Relative database Block Address.

RDBA is computed using datafile# and block_id and we can verify this as shown below. I got 268435588, decimal equivalent of rdba: 0x10000084. You can find the converter below to convert hex to decimal and vice versa

Lets compute the RDBA using file# (64) and block id (132)
SQL> select DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(64,132) from dual;
DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(64,132)
--------------------------------------------
                                   268435588

And we got the same number.  We can even extract the file# and Block id from the decimal equivalent of RDBA

SQL> select DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(268435588) from dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(268435588)
-----------------------------------------------
                                             64
1 row selected.
SQL> select DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(268435588) from dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(268435588)
------------------------------------------------
                                             132
1 row selected.
And therefore we concluded that the RDBA is calculated using file# and Block id

scn: 0x0.3f1c831 seq: 0x01 flg: 0x06 tail: 0xc8310601
scn: 0x0.3f1c831 => scn the block last modified at
seq: 0x01 => block sequence on this scn ( this tells, how many times a block is modified at this scn)
flg: 0x06=> some kind of flag
tail: 0xc8310601=>
SCN + block type + SCN sequence number used to ensure the block consistency
frmt: 0x02 chkval: 0xf684 type: 0x06=trans datafrmt: 0x02 => Oracle7 formated or >=Oracle8 formated block
chkval: 0xf684  => block integrity checking and configured using db_block_checksum init parameter
type: 0x06=trans data =>
block types 

Object id on Block? Y => object id present on block.

 seg/obj: 0x182ed  csc: 0x00.3f1c577  itc: 2  flg: E  typ: 1 - DATA
 seg/obj: 0x182ed => segment/object number
 SQL>select to_number('182ed', 'xxxxxxxxxx') from dual;   
 SQL> select OWNER,OBJECT_NAME,OBJECT_ID from dba_objects where OBJECT_ID='132877586';

csc: 0x00.3f1c577 => Cleanout System Change number
itc: 2 => interested transaction list count. There are 2 transactions interested  in this block. defaults to 1 and is maintained by storage parameters INITRANS and MAXTRANS.flg: E => Free list flag
 


 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0007.020.00007dd6  0x014004e0.2d71.0a  --U-    1  fsc 0x0000.03f1c831
0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000
Itl => The array index for the list, This value is used in the lock byte (lb:) for a row to show
which transaction has locked the row
Xid => The transaction id of a recent transaction that has modified this block. undo segment . undo slot . undo sequence number
Uba => The undo record address. Absolute block address . block sequence number . record within block
Flag=> flag identifying transaction state
----: active (or “never existed” if every field in the Xid is zero).
--U-: Upper bound commit (also set during “fast commit”).
C---: Committed and cleaned out (all associated lock bytes have been reset to zero).
-B--: May be relevant to the recursive transactions for index block splits.
Lck=> Number of rows locked by this transaction in this block.
Scn/Fsc =>  Depending on the Flag, the commit SCN or the number of bytes of free space that would become available if this transaction committed

tsiz: 0x1f98  => total available space in the block
hsiz: 0x14 => current header size
pbl: 0x7f4533ccf264
     76543210
flag=--------
ntab=1  =>
number of tables in this block. Unless this block belongs to a cluster, the value is 1
nrow=1  => number of rows stored in this block.
frre=-1
fsbo=0x14  => Beginning Of Free Space
fseo=0x1f8c => End Of Free Space
avsp=0x1f78 => Available Space
tosp=0x1f78 => Total space
0xe:pti[0]      nrow=1  offs=0 => There are 1 rows in table 0, starting at row 0
0x12:pri[0]     offs=0x1f8c =>  Pointer to the row of table 0
block_row_dump:
tab 0, row 0, @0x1f8c => table 0 , row 0, starting byte position 0x1f8c
tl: 12 fb: --H-FL-- lb: 0x1  cc: 2
tl: 12 => total number of bytes for this row. 
fb: --H-FL-- => row flag value
H=> head of the row
F=> First piece of the row
L=> Last piece of the row
means we have the complete row in the block.
lb: 0x1 => lock byte, coming from Itl
cc: 2 => column count
col  0: [ 2]  c1 02           =>  column number and their values in Hexadecimal format
col  1: [ 5]  54 45 53 54 31  =>  column number and their values in Hexadecimal format
end_of_block_dump

Using Hex to ASCII converter you can read the content of table from this code.
Hex to ASCII Convertor

NOTE:- There are too many things and its nearly impossible to reverse engineer the oracle DB block.
depending the type of block you dump and the status of the block at the moment you are dumping etc you will find more or less information in the dump file.
The overall objective of the post is to provide you an idea, about the oracle database block & row format and how oracle manages them

I hope you like the content. Please feel free to write your comment , feedback , suggestion in the comment section below.

Related Posts


Comments

  1. Everything A Dba Need To Know About Oracle Data Block >>>>> Download Now

    >>>>> Download Full

    Everything A Dba Need To Know About Oracle Data Block >>>>> Download LINK

    >>>>> Download Now

    Everything A Dba Need To Know About Oracle Data Block >>>>> Download Full

    >>>>> Download LINK 6V

    ReplyDelete

Post a Comment

Popular posts from this blog

DataPump Import Of Object Types Fails With Errors ORA-39083 ORA-2304 Or ORA-39117 ORA-39779

<<Back to Oracle DATAPUMP Main Page ORA-39083: Object type TYPE:"TEST_QA01"."LOG_RECORD" failed to create with error: ORA-02304: invalid object identifier literal Import: Release 12.1.0.2.0 - Production on Tue May 29 07:59:12 2018 Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security, OLAP, Advanced Analytics and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/********@TEST_QA parfile=import_TEST.par Processing object type SCHEMA_EXPORT/USER Processing object type SCHEMA_EXPORT/SYSTEM_GRANT Processing object type SCHEMA_EXPORT/ROLE_GRANT Processing object type SCHEMA_EXPORT/DEFAULT_ROLE Pr

ORA-28374: typed master key not found in wallet

<<Back to Oracle DB Security Main Page ORA-46665: master keys not activated for all PDBs during REKEY SQL> ADMINISTER KEY MANAGEMENT SET KEY FORCE KEYSTORE IDENTIFIED BY xxxx WITH BACKUP CONTAINER = ALL ; ADMINISTER KEY MANAGEMENT SET KEY FORCE KEYSTORE IDENTIFIED BY xxxx WITH BACKUP CONTAINER = ALL * ERROR at line 1: ORA-46665: master keys not activated for all PDBs during REKEY I found following in the trace file REKEY: Create Key in PDB 3 resulted in error 46658 *** 2019-02-06T15:27:04.667485+01:00 (CDB$ROOT(1)) REKEY: Activation of Key AdnU5OzNP08Qv1mIyXhP/64AAAAAAAAAAAAAAAAAAAAAAAAAAAAA in PDB 3 resulted in error 28374 REKEY: Keystore needs to be restored from the REKEY backup.Aborting REKEY! Cause: All this hassle started because I accidently deleted the wallet and all wallet backup files too and also forgot the keystore password. There was no way to restore the wallet back. Fortunately in my case the PDB which had encrypted data was supposed to be deco

How to Find VIP of an Oracle RAC Cluster

<<Back to Oracle RAC Main Page How to Find Out VIP of an Oracle RAC Cluster Login clusterware owner (oracle) and execute the below command to find out the VIP hostname used in Oracle RAC $ olsnodes -i node1     node1-vip node2     node2-vip OR $ srvctl config nodeapps -viponly Network 1 exists Subnet IPv4: 10.0.0.0/255.255.0.0/bondeth0, static Subnet IPv6: Ping Targets: Network is enabled Network is individually enabled on nodes: Network is individually disabled on nodes: VIP exists: network number 1, hosting node node1 VIP Name: node1-vip VIP IPv4 Address: 10.0.0.1 VIP IPv6 Address: VIP is enabled. VIP is individually enabled on nodes: VIP is individually disabled on nodes: VIP exists: network number 1, hosting node node2 VIP Name: node2-vip VIP IPv4 Address: 10.0.0.2 VIP IPv6 Address: VIP is enabled. VIP is individually enabled on nodes: VIP is individually disabled on nodes:

How to Power On/off Oracle Exadata Machine

<<Back to Exadata Main Page How to Power On/off Oracle Exadata Machine Oracle Exadata machines can be powered on/off either by pressing the power button on front of the server or by logging in to the ILOM interface. Powering on servers using  button on front of the server The power on sequence is as follows. 1. Start Rack, including switches  Note:- Ensure the switches have had power applied for a few minutes to complete power on  configuration before starting Exadata Storage Servers 2.Start Exadata Storage Servers  Note:- Ensure all Exadata Storage Servers complete the boot process before starting the   database servers 3. Start Database Servers Powering On Servers Remotely using ILOM The ILOM can be accessed using the Web console, the command-line interface (CLI), IPMI, or SNMP. For example, to apply power to server dm01cel01 using IPMI, where dm01cel01-ilom is the host name of the ILOM for the server to be powered on, run the

How to Attach to a Datapump Job and Check Status of Export or Import

<<Back to Oracle DATAPUMP Main Page How to check the progress of  export or import Jobs You can attach to the export/import  job using ATTACH parameter of oracle datapump utility. Once you are attached to the job you check its status by typing STATUS command. Let us see how Step1>  Find the Export/Import Job Name You can find the datapump job information from  DBA_DATAPUMP_JOBS or  USER_DATAPUMP_JOBS view. SQL> SELECT OWNER_NAME,JOB_NAME,OPERATION,JOB_MODE,STATE from DBA_DATAPUMP_JOBS; OWNER_NAME JOB_NAME                       OPERATION            JOB_MODE   STATE ---------- ------------------------------ -------------------- ---------- ---------- SYSTEM     SYS_EXPORT_FULL_02             EXPORT               FULL       EXECUTING OR You can also find the job name for export/import in logfile in beginning itself. Step2>Attach to the Job and check status One you get the Export/Import Job Name attach the job and check its status. You can attach or det

How to Create Pfile from Spfile and Vice Versa

<<Back to DB Administration Main Page There are instances when a DBA need to start the database using pfile, for example to trouble an instance startup error or to validate init file post parameter changes etc. In such situations you can create a pfile from spfile and once you are done with your changes you can create spfile from updated/modified pfile to start the database. How to Create Pfile from Spfile As sysdba execute following command  SQL> create pfile='/tmp/initOrcl.ora' from spfile; How to Create SPfile from Pfile As sysdba execute following command  SQL> create spfile from  pfile='/tmp/initOrcl.ora'; You can also create the pfile directly from memory How to Create Pfile from Memory As sysdba execute following command  SQL> create  pfile='/tmp/initOrcl.ora' from memory;

How to export only data or only metadata using expdp

<<Back to Oracle DATAPUMP Main Page CONTENT parameter of expdp let you select whether you want to export only data or only metadata or both Default : ALL Syntax and Description CONTENT=[ALL | DATA_ONLY | METADATA_ONLY] DATA_ONLY exports only table row data; no database object definitions are exported. METADATA_ONLY exports only database object definitions; no table row data is exported. Exporting metadata only  $ cat exp_full_pdb01.par directory=dump dumpfile=EXP_PDB01_FULL%U.dmp logfile=EXP_PDB01_FULL.log full=y CONTENT=METADATA_ONLY $ expdp system@PDB01 parfile=exp_full_pdb01.par Exporting data only directory=dump dumpfile=EXP_PDB01_FULL%U.dmp logfile=EXP_PDB01_FULL.log full=y CONTENT=DATA_ONLY $ expdp system@PDB01 parfile=exp_full_pdb01.par

ORA-15040: diskgroup is incomplete

<<Back to Oracle ASM Main Page ORA-15040: diskgroup is incomplete SQL> startup ORA-00099: warning: no parameter file specified for ASM instance ASM instance started Total System Global Area 1140850688 bytes Fixed Size                  8629704 bytes Variable Size            1107055160 bytes ASM Cache                  25165824 bytes ORA-15110: no diskgroups mounted Reason: The reason of this error is simply the ASM is not able to find the some or all the disks. Solution: Investigate and make all the disks available to ASM to mount the disk group. Make sure the disks has proper permissions. If you are using AFD check following services are online oracleacfs oracleadvm oracleoks  oracleafd   Source of Problem : Issue started after restart of the server After restarting the server when I tried to start the ASM instance its started throwing error.  ORA-15110: no diskgroups mounted Investigation in my Case Step1> ASM Logfile Scanning  Looked i

Step by Step How to Configure Software Keystore/ Oracle Wallet

<<Back to Oracle DB Security Main Page How to Configure a Software Keystore A software keystore is a container that stores the Transparent Data Encryption master encryption key. To configure a software Keystore follow the steps below. Step 1: Set the Keystore Location in the sqlnet.ora File You can store the software keystore (also known as wallet) in file system or in ASM Diskgroup. Does not matter where you want to store the keystore you have modify the sqlnet.ora and make an entry accordingly Make an entry as shown below in $ORACLE_HOME/network/admin/sqlnet.ora file Example1: If Storing the Wallet in ASM ENCRYPTION_WALLET_LOCATION=  (SOURCE=(METHOD=FILE)    (METHOD_DATA=     (DIRECTORY= +DG_TST_DATA/$ORACLE_SID/wallet )    )  )   Example2: If Storing the Wallet in File System ENCRYPTION_WALLET_LOCATION=  (SOURCE=(METHOD=FILE)    (METHOD_DATA=     (DIRECTORY= /u01/dbatst1/admin/wallet/$ORACLE_SID)    )  ) NOTE: Ensure that the path you entered in  DIREC

ORA-28365: wallet is not open while starting the database

<<Back to DB Administration Main Page ORA-28365: wallet is not open Encountered while Starting the Database $ srvctl start instance -d CDB001 -i CDB0011 PRCR-1013 : Failed to start resource ora.cdb001.db PRCR-1064 : Failed to start resource ora.cdb001.db on node node1.oracle.com CRS-5017: The resource action "ora.cdb001.db start" encountered the following error: ORA-28365: wallet is not open . For details refer to "(:CLSN00107:)" in "/u01/app/oracle/diag/crs/node1.oracle.com/crs/trace/crsd_oraagent_oracle.trc". CRS-2674: Start of 'ora.cdb001.db' on 'node1.oracle.com' failed Solution : Start the instance in mount mode SQL> startup mount; ORACLE instance started. Total System Global Area 2147483648 bytes Fixed Size                  2926472 bytes Variable Size            1392511096 bytes Database Buffers          738197504 bytes Redo Buffers               13848576 bytes Database mounted. Check Wallet status set linesiz