[20171113]修改表结构删除列相关问题4.txt

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: [20171113]修改表结构删除列相关问题4.txt --//连续写了3篇修改表结构删除列的相关问题,链接如下: http://blog.itpub.net/267265/viewspace-2147158/ http://blog.

[20171113]修改表结构删除列相关问题4.txt

--//连续写了3篇修改表结构删除列的相关问题,链接如下:

http://blog.itpub.net/267265/viewspace-2147158/
http://blog.itpub.net/267265/viewspace-2147163/
http://blog.itpub.net/267265/viewspace-2147196/

--//从redo记录日志内容看,日志仅仅记录偏移位置 (piece relative column number),这样日志量还是相对较小,而且与删除字段的位置无关.
--//参考链接:
http://blog.itpub.net/267265/viewspace-2147163/
--//摘取其中1段,注意看下划线部分:

REDO RECORD - Thread:1 RBA: 0x000317.0000009c.0084 LEN: 0x017c VLD: 0x01
SCN: 0x0003.176a162e SUBSCN:  1 11/13/2017 10:13:57
CHANGE #1 TYP:0 CLS:35 AFN:3 DBA:0x00c00110 OBJ:4294967295 SCN:0x0003.176a1592 SEQ:1 OP:5.2 ENC:0 RBL:0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ktudh redo: slt: 0x0009 sqn: 0x0000532a flg: 0x0012 siz: 132 fbi: 0
            uba: 0x00c1cd3c.10c6.10    pxid:  0x0000.000.00000000
CHANGE #2 TYP:0 CLS:36 AFN:3 DBA:0x00c1cd3c OBJ:4294967295 SCN:0x0003.176a1591 SEQ:1 OP:5.1 ENC:0 RBL:0
ktudb redo: siz: 132 spc: 3916 flg: 0x0012 seq: 0x10c6 rec: 0x10
            xid:  0x000a.009.0000532a
ktubl redo: slt: 9 rci: 0 opc: 11.1 [objn: 90617 objd: 90617 tsn: 7]
Undo type:  Regular undo        Begin trans    Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
             0x00000000  prev ctl uba: 0x00c1cd3c.10c6.0f
prev ctl max cmt scn:  0x0003.176a1392  prev tx cmt scn:  0x0003.176a1396
txn start scn:  0xffff.ffffffff  logon user: 83  prev brb: 12700985  prev bcl: 0 BuExt idx: 0 flg2: 0
KDO undo record:
KTB Redo
op: 0x03  ver: 0x01
compat bit: 4 (post-11) padding: 1
op: Z
KDO Op code: DSC row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x01800081  hdba: 0x01800080
itli: 2  ispac: 0  maxfr: 4863
tabn: 0 slot: 0(0x0)
piece relative column number: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CHANGE #3 TYP:2 CLS:1 AFN:6 DBA:0x01800081 OBJ:90617 SCN:0x0003.176a14f9 SEQ:5 OP:11.14 ENC:0 RBL:0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KTB Redo
op: 0x11  ver: 0x01
compat bit: 4 (post-11) padding: 1
op: F  xid:  0x000a.009.0000532a    uba: 0x00c1cd3c.10c6.10
Block cleanout record, scn:  0x0003.176a162e ver: 0x01 opt: 0x02, entries follow...
  itli: 1  flg: 2  scn: 0x0003.176a14f9
KDO Op code: DSC row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x01800081  hdba: 0x01800080
itli: 2  ispac: 0  maxfr: 4863
tabn: 0 slot: 0(0x0)
piece relative column number: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--//还是通过了例子来说明:


0.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//建立测试脚本:
$ cat test1.sql
column name format a54
alter table t1 SET UNUSED (v1,v2,v3);
@ &r/viewredo
set timing on
ALTER TABLE t1 DROP UNUSED COLUMNS ;
set timing off
@ &r/viewredo

1.测试1:
--//drop table t1 purge;
create table t1 (id number,v0 varchar2(50),v1 varchar2(10),v2 varchar2(10),v3 varchar2(10));
insert into t1 select rownum,lpad('a',50,'a'),lpad('b',10,'b'),lpad('c',10,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;

--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          1
redo size                                                     194       8124
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

Table altered.

Elapsed: 00:00:41.41
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          2
redo size                                                     194  687554932
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

--//redo=687554932-8124=687546808

2.测试2:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v0 varchar2(50),v2 varchar2(10),v3 varchar2(10));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',50,'b'),lpad('c',10,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;

--//运行test1.sql:

SCOTT@book> @ test1.sql
Table altered.
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          1
redo size                                                     194       8736
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

Table altered.

Elapsed: 00:00:40.31
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          2
redo size                                                     194  687540264
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

--//redo=687540264-8736=687531528.

3.测试3:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v2 varchar2(10),v0 varchar2(50),v3 varchar2(10));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',10,'b'),lpad('c',50,'c'),lpad('d',10,'d') from xmltable('1 to 1000000');
commit;

--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.

NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          1
redo size                                                     194       8736
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0


Table altered.

Elapsed: 00:00:41.57
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          2
redo size                                                     194  687620720
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

--//redo = 687620720-8736=687611984


4.测试4:
--//drop table t1 purge;
create table t1 (id number,v1 varchar2(10),v2 varchar2(10),v3 varchar2(10),v0 varchar2(50));
insert into t1 select rownum,lpad('a',10,'a'),lpad('b',10,'b'),lpad('c',10,'c'),lpad('d',50,'d') from xmltable('1 to 1000000');
commit;

--//运行test1.sql:
SCOTT@book> @ test1.sql
Table altered.

NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          1
redo size                                                     194       8852
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

Table altered.

Elapsed: 00:00:40.99
NAME                                                   STATISTIC#      VALUE
------------------------------------------------------ ---------- ----------
user commits                                                    6          2
redo size                                                     194  687650544
redo wastage                                                  199          0
data blocks consistent reads - undo records applied           326          0

--//redo =  687650544 - 8852=687641692

5.分析:
--//删除v1,v2,v2列. v0列在测试中处在表的位置依次变化.而oracle的改变向量每次操作一个字段,因为日志中仅仅piece relative column number.
--//大小相对稳定,这样操作日志量大小不存在变化,而且相差很小.

--------------------------
v0出现位置  redo量     时间
---------------------------
         2  687546808  41.41
         3  687531528  40.31
         4  687611984  41.57
         5  687641692  40.99
--------------------------

--// 可以看出redo与时间消耗基本差不多.

6.总结:
--1.删除列不存在相关性.不是越靠前或者后面记录很大,而导致事务发生变化.
--2.感觉采用ctas或者采用在线表重定义也许更好.业务停顿可能更小.事务量还是偏大.

7.附上viewredo.sql脚本:
SELECT b.NAME, a.statistic#, a.VALUE
  FROM v$mystat a, v$statname b
WHERE b.NAME IN ('redo size', 'redo wastage','user commits','data blocks consistent reads - undo records applied') AND a.statistic# = b.statistic#;

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
关系型数据库 MySQL Java
给数据表添加或者删除列|学习笔记
快速学习给数据表添加或者删除列
135 0
|
设计模式 数据库
Access2016删除主键列(图文操作)错误提示:若要删除主键,请在“设计”视图中打开该表并删除主键字段
Access2016删除主键列(图文操作)错误提示:若要删除主键,请在“设计”视图中打开该表并删除主键字段
Access2016删除主键列(图文操作)错误提示:若要删除主键,请在“设计”视图中打开该表并删除主键字段
|
存储 SQL 数据库
DM8数据库批量创建表,插入数据,更改表信息,删除测试
在测试产品的功能和性能的时候需要大量数据表,我们可以通过**游标**和**存储过程**批量创建测试表,插入测试数据,更改测试表,删除测试表。
|
SQL
SQL|表中添加、删除或修改列。
ALTER TABLE 语句用于在已有的表中添加、删除或修改列。 ALTER TABLE 语法 如需在表中添加列,请使用下面的语法: ALTER TABLE table_name ADD column_name datatype 如需删除表中的列,...
995 0
|
关系型数据库 MySQL 机器学习/深度学习
|
SQL Oracle 关系型数据库
[20171113]修改表结构删除列相关问题.txt
[20171113]修改表结构删除列相关问题.txt --//维护表结构删除字段一般都是先 ALTER TABLE SET UNUSED (); --//然后等空闲时候删除列.
857 0
|
Oracle 关系型数据库
[20171113]修改表结构删除列相关问题3.txt
[20171113]修改表结构删除列相关问题3.txt --//维护表结构删除字段一般都是先 ALTER TABLE SET UNUSED (); --//然后等空闲时候删除列.
778 0
|
Oracle 关系型数据库 数据库管理
[20171113]修改表结构删除列相关问题2.txt
[20171113]修改表结构删除列相关问题2.txt --//测试看看修改表结构删除列产生的redo向量,对这些操作细节不了解,分析redo看看. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING             ...
1041 0
|
Oracle 关系型数据库 OLAP
[20160910]快速修改表的schema.txt
[20160910]快速修改表的schema.txt --以前也做过例子: http://blog.itpub.net/267265/viewspace-741154/ http://blog.itpub.net/267265/viewspace-744787/ --第1种就是修改数据字典的情况,但是这种存在一定的风险,我当时的测试版本11.2.0.1还有修改obj$的字段spare3. --第2种就是利用交换分区的方法。
842 0