Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Author JP Vijaykumar
Date Sept 14th 2009
--Create a database.
connect / as sysdba
startup nomount pfile=/u001/oracle/product/10.2.0/db_1/dbs/initsavi.ora
create database SAVI
datafile '/u101/oradata/SAVI/systemsavi01.dbf' size 500m reuse
sysaux datafile '/u101/oradata/SAVI/sysaux.dbf' size 500m reuse
undo tablespace UNDOSAVI datafile
'/u101/oradata/SAVI/undosavi01.dbf' size 50m reuse
default temporary tablespace TEMPSAVI
tempfile '/u101/oradata/SAVI/tempsavi01.dbf' size 10m reuse
logfile group 1 ('/u101/oradata/SAVI/redosavi01.rlg') size 10m reuse,
group 2 ('/u101/oradata/SAVI/redosavi02.rlg') size 10m reuse
controlfile reuse;
--Create a tablespace.
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for HPUX: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
--Create a table.
SQL> declare
2 begin
3 for i in 1..5 loop
4 insert into VEEKSHA values(i);
5 commit;
6 end loop;
7 end;
8 /
PL/SQL procedure successfully completed.
5 rows selected.
1 row selected.
5 rows selected.
Table truncated.
--Insert five string values using a pl/sql sting parser.
22
333
4444
55555
22
AAACYgAAEAAAAEaAAB 2 15 333
4444
55555
2 rows selected.
--Strangely the inserted five values are treated by Oracle as two records.
--Oracle had spread each record into multiple rows.
--The row length of the first record is 6 bytes, that of second record is 15 bytes.
22 6
333
4444
55555 15
--The length and value of the two records are displayed from the table through a pl/sql loop.
22
1 row selected.
55555
1 row selected.
COL1
---------------
1
22
1 row selected.
RNUM COL1
---------- ---------------
2 333
4444
55555
1 row selected.
1 row selected.
2 rows selected.
55555
1 row selected.
COL1
---------------
333
4444
55555
1 row selected.
COL1
---------------
333
4444
55555
1 row selected.
COL1
---------------
1
22
333
4444
55555
2 rows selected.
COL1
---------------
1
22
1 row selected.
Procedure created.
NAME
--------------------------------------------------------------------------------
/u101/oradata/SAVI/savi_data_01.dbf
1 row selected.
$ ./bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Tue Oct 6 17:13:18 2009
BBED> x /rnccntnnn
rowdata[8] @8167
----------
flag@8167: 0x34 (KDRHFL, KDRHFD, KDRHFH)
lock@8168: 0x34
cols@8169: 0
BBED> find /c 22
File: /u101/oradata/SAVI/savi_data_01.dbf (0)
Block: 282 Offsets: 8185 to 8191 Dba:0x00000000
------------------------------------------------------------------------
323220ed 8b0601
BBED> exit
$ ./bbed
Password:
BBED> exit
$ ./bbed
Password:
BBED> find /c 22
File: /u101/oradata/SAVI/systemsavi01.dbf (1)
Block: 282 Offsets: 7933 to 8191 Dba:0x0040011a
------------------------------------------------------------------------
3232fe00 400e6e03 c22a4bfe 00400e6d 03c2295e 02c11200 400e6c03 c22813fe
00400e6b 03c22517 fe00400b 9403c224 4bfe0040 0b9303c2 241302c1 0e00400b
9203c223 4bfe0040 0b9103c2 1d0cfe00 400b9003 c21c47fe 00400b8f 03c21c0c
fe00400b 8e03c21b 28fe0040 0b8d03c2 195ffe00 400b8c03 c2193fff 00400b8b
03c21935 fe00400b 8a03c219 2b02c114 00400b89 03c21905 02c11a00 400b8803
c2184202 c10f0040 0b8703c2 1822fe00 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 0000007f
140601
BBED> find / c 1
File: /u101/oradata/SAVI/savi_data_01.dbf (4)
Block: 282 Offsets: 8182 to 8191 Dba:0x0100011a
------------------------------------------------------------------------
310a0a32 3220ed8b 0601
BBED> find / c 22
File: /u101/oradata/SAVI/savi_data_01.dbf (4)
Block: 282 Offsets: 8185 to 8191 Dba:0x0100011a
------------------------------------------------------------------------
323220ed 8b0601
BBED> show
FILE# 4
BLOCK# 282
OFFSET 8185
DBA 0x0100011a (16777498 4,282)
FILENAME /u101/oradata/SAVI/savi_data_01.dbf
BIFILE bifile.bbd
LISTFILE /u101/oradata/SAVI/jp.log
BLOCKSIZE 8192
MODE Browse
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 128
LOGFILE log.bbd
SPOOL No
BBED> x /rcnn
rowdata[26] @8185
-----------
flag@8185: 0x32 (KDRHFP, KDRHFD, KDRHFH)
lock@8186: 0x32
cols@8187: 0
BBED> p *kdbr[1]
rowdata[0]
----------
ub1 rowdata[0] @8159 0x2c
BBED> p *kdbr[2]
BBED-00401: out of range array index (2)
BBED> p *kdbr[0]
rowdata[19]
-----------
ub1 rowdata[19] @8178 0x2c
BBED> x /1rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
BBED> x /2rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
tailchk @8188
-------
BBED-00210: no row at this offset
BBED> x /3rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
tailchk @8188
-------
BBED-00210: no row at this offset
BBED> x /4rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
tailchk @8188
-------
BBED-00210: no row at this offset
BBED> x /5rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
tailchk @8188
-------
BBED-00210: no row at this offset
BBED> x /6rcnn
rowdata[19] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 1
tailchk @8188
-------
BBED-00210: no row at this offset
--Took a dump of the Oracle block 282.
$cat savi_ora_28660.trc
/u101/oradata/SAVI/udump/savi_ora_28660.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /u001/oracle/product/10.2.0/db_1
System name: HP-UX
Node name: wmsdb09
Release: B.11.23
Version: U
Machine: ia64
Instance name: SAVI
Redo thread mounted by this instance: 1
Oracle process number: 13
Unix process pid: 28660, image: oracle@wmsdb09 (TNS V1-V3)
...............
...............
...............
Repeat 1 times
60000000001ECB80 2D2D2D2D FFFFFFFF FFFFFFFF FFFFFFFF [----............]
60000000001ECB90 02C10602 C10606C5 0625580A 0D018003 [.........%X.....]
60000000001ECBA0 C20825FF FFFFFF07 786D0A06 102727AC [..%.....xm...''.]
60000000001ECBB0 00010008 00080040 11A70003 004011A7 [.......@.....@..]
60000000001ECBC0 000303C2 2D306C00 140202C1 0402C104 [....-0l.........]
60000000001ECBD0 02C22901 800B434C 495F434F 4D4D454E [..)...CLI_COMMEN]
60000000001ECBE0 5402C102 02C22901 80FFFF01 80FFFF02 [T.....).........]
60000000001ECBF0 C1040180 02C10202 C1020180 018002C2 [................]
60000000001ECC00 296C0014 0202C103 02C10302 C2020180 [)l..............]
60000000001ECC10 0F455850 4F52545F 46554E43 54494F4E [.EXPORT_FUNCTION]
60000000001ECC20 02C10202 C2020180 FFFF0180 FFFF02C1 [................]
60000000001ECC30 03018002 C10202C1 02018001 8002C202 [................]
60000000001ECC40 6C001402 02C10202 C10202C1 1F01800B [l...............]
60000000001ECC50 434C4945 4E545F4E 414D4502 C10202C1 [CLIENT_NAME.....]
60000000001ECC60 1F0180FF FF02C102 FFFF02C1 02018002 [................]
60000000001ECC70 C10202C1 02018001 8002C11F 6C002402 [............l.$.]
60000000001ECC80 03C22D2E 018002C1 0203C233 05FFFF02 [..-........3....]
60000000001ECC90 C104FF02 C10B02C1 2902C102 03C20338 [........)......8]
60000000001ECCA0 02C10226 2D2D2D2D 2D2D2D2D 2D2D2D2D [...&------------]
60000000001ECCB0 2D2D2D2D 2D2D2D2D 2D2D2D2D 2D2D2D2D [----------------]
60000000001ECCC0 2D2D2D2D 2D2D2D2D 2D2DFFFF FFFFFFFF [----------......]
60000000001ECCD0 FFFFFFFF FFFF02C1 0402C104 06C50625 [...............%]
60000000001ECCE0 580A0D01 8003C208 25FFFFFF FF07786D [X.......%.....xm]
60000000001ECCF0 0A061027 276C0021 0203C22D 2F03C22D [...''l.!...-/..-]
60000000001ECD00 2F018002 C10203C2 33070180 02C10202 [/.......3.......]
60000000001ECD10 C10B02C1 0303C203 38FF02C1 02018003 [........8.......]
60000000001ECD20 C22962FF FFFFFFFF FFFFFFFF 02C102FF [.)b.............]
60000000001ECD30 FFFF02C1 02FFFFFF FF07786D 0A061027 [..........xm...']
60000000001ECD40 276C0009 0203C22D 2F02C102 02C10201 ['l.....-/.......]
60000000001ECD50 80018001 8002C102 01800180 AC000100 [................]
60000000001ECD60 06000600 4011A700 02004011 A7000203 [....@.....@.....]
60000000001ECD70 C22D2E6C 00020126 2D2D2D2D 2D2D2D2D [.-.l...&--------]
60000000001ECD80 2D2D2D2D 2D2D2D2D 2D2D2D2D 2D2D2D2D [----------------]
60000000001ECD90 2D2D2D2D 2D2D2D2D 2D2D2D2D 2D2D0180 [--------------..]
60000000001ECDA0 AC000100 01000100 4011A700 01004011 [........@.....@.]
60000000001ECDB0 A7000103 C22D2D6C 00020026 2D2D2D2D [.....--l...&----]
60000000001ECDC0 2D2D2D2D 2D2D2D2D 2D2D2D2D 2D2D2D2D [----------------]
60000000001ECDD0 2D2D2D2D 2D2D2D2D 2D2D2D2D 2D2D2D2C [---------------,]
60000000001ECDE0 01010F33 33330A34 3434340A 0A353535 [...333.4444..555] <- Second
row value
60000000001ECDF0 35352C01 0106310A 0A323220 ED8B0601 [55,...1..22 ....] <- First row
value
Block header dump: 0x0100011a
Object id on Block? Y
seg/obj: 0x2620 csc: 0x00.2ec18 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1000109 ver: 0x01 opc: 0
inc: 0 exflg: 0
no rows selected
no rows selected
no rows selected
Why and how Oracle inserted a single record into multiple rows, is a puzzle.
--Let us display the string value and length from the pl/sql string parser.
5 6 22 333
7 4444
8
9 55555';
10
11 begin
12 while (i <length(v_str)) loop
13 begin
14
15 j:=instr(substr(v_str,i,length(v_str)),' ');
16
17 if ( j = 0 ) then
18 j:=length(v_str);
19 end if;
20
21 if (( substr(v_str,i,1) <> ' ' ) and ( substr(v_str,i,1) IS NOT NULL ) )
then
22 dbms_output.put_line(substr(v_str,i,j)||' '||length(substr(v_str,i,j)));
23 --insert into VEEKSHA values(substr(v_str,i,j));
24 end if;
25
26 i:=i+j;
27
28 exception
29 when others then
30 dbms_output.put_line(sqlerrm);
31 end;
32 end loop;
33 end;
34 /
1
4
22 3
333
5
4444
7
55555 5
1 row created.
COL1
---------------
1
22
1 row created.
SQL> commit;
Commit complete.
COL1
---------------
1
22
333
4444
55555
--Inserted a second record into the table and displayed the records
with rowid, rownum, length of col1 and col1 value.
AAA4FAAABAAANdiAAB 2 14 333
4444
55555
Table dropped.
Table created.
1 row created.
1 row created.
SQL> commit;
Commit complete.
2 si 10-OCT-09
t
a
--Inserted two record into the table that were spread into multiple rows successfully.
AAA4FBAABAAANdiAAB 2 7 2 si 10-OCT-09
t
a
--From the above inserts, it is evident, Oracle is not counting the nulls between the
inserted string values, that were generated with an <ENTER>.
How could Oracle insert a record into multiple rows is a puzzle to decypher.
References:
http://www.databasejournal.com/scripts/article.php/3678311
http://www.databasejournal.com/features/oracle/article.phpr/3758471
http://www.databasejournal.com/scripts/article.php/3828731/Nulli-Secundus.htm
http://www.dbasupport.com/oracle/ora10g/bbed.shtml
http://www.dbasupport.com/oracle/ora10g/bbed02.shtml
http://www.orafaq.com/papers/dissassembling_the_data_block.pdf
http://translate.google.com/translate?hl=en&sl=ru&u=http://vpahom.blogspot.com/2009/05/bbed-
block-browser-and-editor.html&ei=7AXMSs60Ls-
Ytgf5g9m5Bw&sa=X&oi=translate&resnum=1&ct=result&prev=/search%3Fq%3D
%2522BBED-00312:%2Bno%2BLISTFILE%2Bspecified%2522%26hl%3Den%26sa%3DG