- 浏览: 191613 次
- 性别:
- 来自: 杭州
文章分类
最新评论
First of all let’s create a new tablespace and a table:
SQL> create tablespace my_tbs datafile '/u01/oradata/chenlin/my_tbs.dbf' size 200m ;
Tablespace created.
then:
SQL> create table my_tab tablespace my_tbs as select * from dba_objects ;
Table created.
Now let’s get more information about this table from DBA_SEGMENTS view:
SQL> select header_file, header_block, bytes, blocks, extents from dba_segments where segment_name='MY_TAB';
HEADER_FILE HEADER_BLOCK BYTES BLOCKS EXTENTS
----------- ------------ -------- ---------- ----------
12 17 4194304 1024 19
From the output we can say that the header block of the table is stored in the datafile 12, block 17.
The size of the table 4194304 bytes (4.2 Mb) and it contains 1024 blocks and 19 extents.
After getting block size of the database, let’s do some math:
SQL> show parameter db_block_size
NAME TYPE VALUE
-------------- ----------- --------------------------
db_block_size integer 4096
BLOCKS (dba_segments) * DB_BLOCK_SIZE (parameter file) = BYTES (dba_segments)
so : 1024 * 4096 = 4194304
Now let’s query DBA_EXTENTS view to get some information on extents and data blocks of this table:
SQL> col segment_name format a20
SQL> select segment_name, extent_id, block_id, blocks, bytes from dba_extents where segment_name='MY_TAB';
SEGMENT_NAME EXTENT_ID BLOCK_ID BLOCKS BYTES
-------------------- ---------- ---------- ---------- -------
MY_TAB 0 17 16 65536
MY_TAB 1 33 16 65536
MY_TAB 2 49 16 65536
MY_TAB 3 65 16 65536
MY_TAB 4 81 16 65536
MY_TAB 5 97 16 65536
MY_TAB 6 113 16 65536
MY_TAB 7 129 16 65536
MY_TAB 8 145 16 65536
MY_TAB 9 161 16 65536
MY_TAB 10 177 16 65536
MY_TAB 11 193 16 65536
.............................
19 rows selected.
we do this test by follow info :
SEGMENT_NAME EXTENT_ID BLOCK_ID BLOCKS BYTES
-------------------- --------- --------- ---------- ----------
MY_TAB 0 17 16 65536
MY_TAB 1 33 16 65536
Here we see that the first extent (0) contains 16 blocks which id range between 17 and 33 ,
so: 17 (block_id) + 16 (number of blocks) = 33 (block_id of the next extent)
And 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
SQL> select header_file, header_block from dba_segments where segment_name='MY_TAB';
HEADER_FILE HEADER_BLOCK
----------- ------------
12 17
See more about dba_segments:
http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_4097.htm#i1626854
Now, dump the data block 12 of the datafile 17:
notice :you should rm your udump file by force first , and relogin again
SQL> alter system dump datafile 12 block 17;
System altered.
If you use SecureCRT , you can use the command : rz or sz to download or upload files
Clone a new session and change to oracle user by using : su - oracle
[oracle@chance udump]$ ll
total 4
-rw-r----- 1 oracle oinstall 2106 May 6 22:15 chenlin_ora_7831.trc
[oracle@chance udump]$sz chenlin_ora_7831.trc
rz
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring chenlin_ora_7831.trc...
100% 2 KB 2 KB/s 00:00:01 0 Errors
Let's find the file chenlin_ora_7831.trc at C:\Users\Administrator\Downloads and see the infomation in it :
#---------------------------------begin--------------------------
/u01/admin/chenlin/udump/chenlin_ora_7831.trc
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
ORACLE_HOME = /u01/oracle
System name:Linux
Node name:chance
Release:2.6.9-89.EL
Version:#1 Mon Jun 22 12:19:40 EDT 2009
Machine:i686
Instance name: chenlin
Redo thread mounted by this instance: 1
Oracle process number: 14
Unix process pid: 7831, image: oracle@chance (TNS V1-V3)
*** SESSION ID:(11.17) 2012-05-06 22:15:42.270
Start dump data blocks tsn: 14 file#: 12 minblk 17 maxblk 17
buffer tsn: 14 rdba: 0x03000011 (12/17)
scn: 0x0000.000a40da seq: 0x01 flg: 0x04 tail: 0x40da1001
frmt: 0x02 chkval: 0x28a8 type: 0x10=DATA SEGMENT HEADER - UNLIMITED
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 19 #blocks: 1023
last map 0x00000000 #maps: 0 offset: 2080
Highwater:: 0x03000351 ext#: 18 blk#: 64 ext size: 256
#blocks in seg. hdr's freelists: 0
#blocks below: 831
mapblk 0x00000000 offset: 18
Unlocked
Map Header:: next 0x00000000 #extents: 19 obj#: 30558 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x03000012 length: 15
0x03000021 length: 16
0x03000031 length: 16
0x03000041 length: 16
0x03000051 length: 16
0x03000061 length: 16
0x030000c1 length: 16
0x030000d1 length: 16
0x030000e1 length: 16
0x030000f1 length: 16
0x03000101 length: 16
0x03000111 length: 256
0x03000211 length: 256
0x03000311 length: 256
nfl = 1, nfb = 1 typ = 1 nxf = 0 ccnt = 0
SEG LST:: flg: UNUSED lhd: 0x00000000 ltl: 0x00000000
End dump data blocks tsn: 14 file#: 12 minblk 17 maxblk 17
#---------------------------------------end------------------------------------------
* Start dump data blocks tsn: 14 file#: 12 minblk 17 maxblk 17
This means that the following lines is the output of datafile 17, block 17. Range of blocks can be given to dump:
SQL> alter system dump datafile 1 block min 1 block max 17
* rdba: 0x03000011
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.
if we want to convert 0x03000011 to decimal, we would get 12/17 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 (0x03000011) to decimal and got 50331665.
In order to convert hexadecimal value to the decimal online, you can use the following link:http://www.statman.info/conversions/hexadecimal.html
SQL> select DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(50331665) as fileNo , DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(50331665) as blockNo from dual;
FILENO BLOCKNO
---------- ----------
12 17
By using DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS function and passing file and block value, we can get RDA value:
SQL> select DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(12,17) from dual;
DBMS_UTILITY.MAKE_DATA_BLOCK_ADDRESS(12,17)
-------------------------------------------
50331665
* scn: 0x0000.000a40dais 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 0×0000.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:
The SCN value of the data block is 0×0000.02eeaf02.
If second part of this value (000a40da) is converted to the decimal, then we got – 671962. If we query the current_scn value we got:
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
683658
* 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 9 or Oracle 10 and higher block. 0×02 represents that it’s Oracle 8 and higher block. (0×01 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, and you show set the parameter db_block_checksum to true in init.ora file
* type : Type defines which type of block it is. In this example it is “Data Segment Header”
* Extent Header: spare1: 0 spare2: 0 #extents: 19 #blocks: 1023
Then in the Extent Control Header part we can get information about extents. So it has 19 extents and 1023 blocks.
* Highwater: 0x03000351 ext#: 18 blk#: 64 ext size: 256
#blocks in seg. hdr's freelists: 0
#blocks below: 831
Highwater mark ( 50332497 ) is at extent 18, block 64. This extent has 256 blocks. And there’re 831 data block below it. Let’s do some math:
As it has 831 blocks below and the number of block is 1023 (dump file didn’t count the header block), then there’re 1023-831=192 data blocks free (and above the hightwater mark).
Moreover, as the highwater mark is at block 64 and the extent has 256 data blocks, then 256-64 = 192 data blocks are free,
So this means that there’s 192*4096 = 786432 bytes (768Kb) free space left
* Map Header: next 0x00000000 #extents: 19 obj#: 30558 flag: 0x40000000
Next, we got object id. To find more details on that object, query sys.obj# view:
SQL> set lines 180
SQL> select obj#, owner#, name, status, ctime, type# from sys.obj$ where obj#=30558;
OBJ# OWNER# NAME STATUS CTIME TYPE#
------- ------- ------- ---------- --------- ----
30558 0 MY_TAB 1 06-MAY-12 2
SQL> select username from dba_users where user_id=0;
USERNAME
------------------------------
SYS
So we can see the owner id is 0 (SYS user) and type is 2 (it means table)
In order to show the free space, we can use DBMS_SPACE.UNUSED_SPACE procedure. Let’s create procedure :
SQL> create or replace procedure show_space
( p_segname in varchar2,
p_owner in varchar2 default user,
p_type in varchar2 default 'TABLE',
p_partition in varchar2 default NULL )
authid current_user
as
l_free_blks number;
l_total_blocks number;
l_total_bytes number;
l_unused_blocks number;
l_unused_bytes number;
l_LastUsedExtFileId number;
l_LastUsedExtBlockId number;
l_LAST_USED_BLOCK number;
procedure p( p_label in varchar2, p_num in number )
is
begin
dbms_output.put_line( rpad(p_label,40,'.') ||
p_num );
end;
begin
dbms_space.unused_space
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
partition_name => p_partition,
total_blocks => l_total_blocks,
total_bytes => l_total_bytes,
unused_blocks => l_unused_blocks,
unused_bytes => l_unused_bytes,
LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
LAST_USED_BLOCK => l_LAST_USED_BLOCK );
p( 'Total Blocks', l_total_blocks );
p( 'Total Bytes', l_total_bytes );
p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
p( 'Unused Blocks', l_unused_blocks );
p( 'Unused Bytes', l_unused_bytes );
p( 'Last Used Ext FileId', l_LastUsedExtFileId );
p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
p( 'Last Used Block', l_LAST_USED_BLOCK );
end show_space;
/
SQL> set serveroutput on
SQL> exec show_space('MY_TAB','SYS');
Total Blocks............................1024
Total Bytes.............................4194304
Total MBytes............................4
Unused Blocks...........................192
Unused Bytes............................786432
Last Used Ext FileId....................12
Last Used Ext BlockId...................785
Last Used Block.........................64
PL/SQL procedure successfully completed.
As it has 831 blocks below and the number of block is 1023 (dump file didn’t count the header block), then there’re 1023-831=192 data blocks free (and above the hightwater mark)
Moreover, as the highwater mark is at block 64 and the extent has 256 data blocks, then 256-64 = 192 data blocks are free,
So this means that there’s 192*4096 = 786432 bytes (768Kb) free space left .
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.
ps: 如果你想真正知道oracle的block块里面真正有些什么,请耐心读完这篇文章~
发表评论
-
oracle数组游标批量插入
2013-12-07 16:40 3390declare type ary is table ... -
使用PL/SQL DEVELOPER 经常会碰到“DYNAMIC PERFORMANCE TABLES NOT ACCESSIBLE”错误
2012-10-16 08:45 934在使用PL/SQL Developer工具登陆一个新 ... -
buffer busy waits 等待事件(热点块竞争)
2012-08-31 16:31 1742*************************** ... -
ora-00054:resource busy and acquire with nowait specified解决方法
2012-06-16 09:35 948当某个数据库用户在数据库中插入、更新、删除一个表的数据, ... -
Oracle 9i 使用Statpack snap 步骤和说明
2012-06-14 08:40 17461、telnet到远程的数据库服务器 CMD>t ... -
oracle Statspack 报告解析之 Shared Pool Statistics(共享池统计信息)
2012-06-21 12:57 1221Shared Pool Statistics ... -
ORACLE里锁模式v$locked_object , locked_mode
2012-06-16 09:37 1449ORACLE里锁有以下几种模式: 0:none ... -
Oracle全面优化:如何对Oracle进行系统的全面优化?
2012-06-13 08:36 1195数据库系统和操作系统一样,在计算机上安装成功后,还需要进 ... -
oracle 参数 FAST_START_MTTR_TARGET
2012-06-14 08:41 1282参数FAST_START_MTTR_TARGET ... -
ORA-12519: TNS:no appropriate service handler found 解决
2012-06-15 08:35 839ORA-12519: TNS:no appropriat ... -
oracle 10g dataguard搭建步骤
2012-06-17 08:49 1725一、主库操作 1、修改主库属性: alter sys ... -
oracle Statspack 报告解析之 Top 5 Timed Events(等待事件)
2012-06-20 08:29 2005常见等待事件说明: ... -
index cluster/hash cluster/sort hash cluster
2012-06-15 08:36 1259簇是一个或多个表的组合,这些表的数据存储在相同的数据块 ... -
Oracle flashback几种方式
2012-06-20 08:26 692flashback(闪回)是Oracle10 ... -
ORACLE Audit 审计
2012-06-21 12:58 13371、什么是审计 审计(A ... -
Oracle建立用户 ,限制用户访问资源
2012-06-14 08:38 1115一、目的: Oracle系 ... -
oracle block 格式
2012-06-19 08:35 1091create table t(n number); ... -
oracle Statspack 报告解析之 Load Profile
2012-06-21 12:57 2100该部分提供每秒和每个事物的统计信息,是监控系统吞吐量和负载变化 ... -
数据库突然变慢,怎么办?
2012-06-16 09:38 2880第一章 检查系统的状态 1.1 使用sar来检查操作系 ... -
oracle library cache 中的hash算法原理
2012-06-18 08:24 1124详细文章:http://bkeep.blog.163.com/ ...
相关推荐
【作品名称】:基于servlet+jsp+mysql实现的影视管理系统【课程设计】 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】: 基于servlet+jsp+mysql实现的影视管理系统【课程设计】 基于servlet+jsp+mysql实现的影视管理系统【课程设计】 Java Web课程设计,基于servlet+jsp+ajax+mysql做的影视管理系统 运行环境: Tomcat 9.0 JDK 1.8 MySQL 8.0 后台管理账号密码均为:root,项目依赖:lib 目录 【资源声明】:本资源作为“参考资料”而不是“定制需求”,代码只能作为参考,不能完全复制照搬。需要有一定的基础看懂代码,自行调试代码并解决报错,能自行添加功能修改代码。
kernel-5.15-ky10-x86.tar.gz
【作品名称】:基于AT89C51 单片机为核心器件,程序设计采用C 语言,Keil 软件编译程序,配以相关外围接口电路,实现了方波、锯齿波、正弦波、三角波、梯形波五种特定波形的产生【论文+源码】 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】:本设计中的波形发生器系统要求基于51单片机,因此选用以AT89C51单片机作为整个系统的控制核心,应用其强大的接口功能,构成整个波形发生器的硬件系统。使用C 语言对单片机编程可产生相应的正弦波,方波,三角波,锯齿波梯形波波形信号。在程序运行时,当接收到按键信息后,需要输出某种波形时,调用相应的中断服务子程序和波形发生程序,经电路的数/模转换器和运算放大器处理后,从信号发生器的输出端口输出即可得到要求的波形。 当需要改变频率时只需要改变单片机的波形发生程序中的递增或者递减变量即可。 【资源声明】:本资源作为“参考资料”而不是“定制需求”,代码只能作为参考,不能完全复制照搬。需要有一定的基础看懂代码,自行调试代码并解决报错,能自行添加功能修改代码。
基于java的法律咨询系统设计与实现.docx
适用于元营销 API 的 Python SDK适用于 Python 的 Facebook Business SDK 介绍Facebook Business SDK是一站式服务,可帮助我们的合作伙伴更好地服务于他们的业务。合作伙伴正在使用多个 Facebook API 来满足其客户的需求。采用所有这些 API 并在各个平台上保持最新状态可能非常耗时,而且最终会造成高昂的成本。为此,Facebook 开发了 Business SDK,将其许多 API 捆绑到一个 SDK 中,以简化实施和维护。Business SDK 是 Marketing API SDK 的升级版,其中包括 Marketing API 以及来自不同平台(如 Pages、Business Manager、Instagram 等)的许多 Facebook API。快速入门商业SDK入门指南Python 目前是我们第三方开发人员最常用的语言。是一个 Python 包,它提供了您的 Python 应用程序与Business SDK 内的 Facebook APIfacebook_business之间的
数学建模培训资料 数学建模实战题目真题答案解析解题过程&论文报告 公交车调度的运作数学模型 共12页.pdf
smart-http 是一款可编程的 Http 应用微内核,方便用户根据自身需求进行 Server 或 Client 的应用开发。支持GET、POST的 HTTP 请求。提供了 URL 路由组件,可以快速搭建一套静态服务器。支持部分 RFC2612 规范,后续会逐渐完善。支持 Https 协议,由 smart-socket 为其赋能。具备文件上传的能力。支持 websocket、Cookie支持 Server、Client 开发
新闻资讯系统 微信小程序+SpringBoot毕业设计 源码+数据库+论文+启动教程 项目启动教程:https://www.bilibili.com/video/BV1oiBpYcEBp
高校师生工作室-JAVA-基于微信小程序的高校师生工作室管理系统的设计与实现
基于java的常见小儿疾病中医护理系统设计与实现.docx
本教程播放列表涵盖了 Python 中的数据结构和算法。每个教程都有数据结构或算法背后的理论、BIG O 复杂性分析和可供练习的练习。使用 Python 的数据结构和算法本教程涵盖了 Python 中的数据结构和算法。每个教程都包含数据结构或算法背后的理论、BIG O 复杂度分析以及可供练习的练习。要观看视频,您可以访问播放列表https://www.youtube.com/playlist?list=PLeo1K3hjS3uu_n_a__MI_KktGTLYopZ12订阅 codebasics youtube 频道https://www.youtube.com/c/codebasics
数学建模学习资料 蒙特卡罗方法课件教程 第2章.随机数 共29页.pptx
python实现基于CNN网络的新闻数据集文本分类源码+数据集(Python期末大作业),个人大三学期的期末大作业、经导师指导并认可通过的高分大作业设计项目,评审分98分。主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业。 python实现基于CNN网络的新闻数据集文本分类源码+数据集(Python期末大作业)python实现基于CNN网络的新闻数据集文本分类源码+数据集(Python期末大作业),个人大三学期的期末大作业、经导师指导并认可通过的高分大作业设计项目,评审分98分。主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业。python实现基于CNN网络的新闻数据集文本分类源码+数据集(Python期末大作业),个人大三学期的期末大作业、经导师指导并认可通过的高分大作业设计项目,评审分98分。主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业。python实现基于CNN网络的新闻数据集文本分类源码+数据集(Python期末大作业),个人大
中小学知识产权教育试点学校申报表.doc
基于django的音乐推荐系统.zip
在建工程涉及专项行动情况检查表.docx
本项目是一个基于Python技术的学生管理系统,采用Django框架进行开发,旨在为计算机相关专业的学生提供一个实践性强、功能全面的管理系统,以帮助他们完成毕业设计或进行项目实战练习。 系统实现了对学生信息、课程信息、成绩、考勤等多方面的管理功能。学生信息管理包括学生基本信息的增删改查;课程信息管理允许管理员设置课程信息,包括课程名称、授课老师、学分等;成绩管理功能使学生和教师能够录入、查看和修改成绩;考勤管理则方便教师记录学生的出勤情况。 该项目采用B/S架构,前端使用HTML、CSS、JavaScript等技术,后端使用Python语言和Django框架,数据库采用MySQL。Django框架提供了强大的后台管理功能,使得系统管理更加便捷。 通过开发这个项目,学生不仅能提升自己的编程能力,还能学习到如何构建一个实际应用的系统,对于即将步入职场的学生来说,具有很高的实用价值。
适用于 Python 的 Splunk 软件开发工具包参考文档适用于 Python 的 Splunk Enterprise 软件开发工具包版本 2.1.0适用于 Python 的 Splunk Enterprise 软件开发套件 (SDK) 包含库代码,旨在使开发人员能够使用 Splunk 平台构建应用程序。Splunk 平台是一个搜索引擎和分析环境,它使用分布式 map-reduce 架构来有效地索引、搜索和处理大型时变数据集。Splunk 平台深受系统管理员的欢迎,用于聚合和监控 IT 机器数据、安全性、合规性以及各种其他场景,这些场景都需要有效地从大量时间序列数据中索引、搜索、分析和生成实时通知。Splunk 开发者平台使开发人员能够利用 Splunk 平台所使用的相同技术来构建令人兴奋的新应用程序。开始使用 Python 版 Splunk SDK开始使用 Python 版 Splunk Enterprise SDKSplunk Enterprise SDK for Python 包含库代码,其示例位于splunk-app-examples存储库
分布式事务练习
家庭财务管理系统 微信小程序+SSM毕业设计 源码+数据库+论文+启动教程 项目启动教程:https://www.bilibili.com/video/BV1BfB2YYEnS