我们初始化了一下的数据。 我们创建基表用户ref_owner,连接用户ref_conn 创建基表test_online_ref ## init set echo on create user ref_owner identified by oracle; create user ref_conn identified by oracle; grant connect,resource to ref_owner; grant connect to ref_conn; grant create synonym to ref_conn;
##owner account: ref_owner conn ref_owner/oracle
CREATE TABLE test_online_ref ( col1 varchar2(30), col2 DATE ) ; alter table test_online_ref modify(col1 primary key); 生成近300万数据 insert into test_online_ref select level,sysdate+level*0.01 from dual connect by level<3000000; commit; grant select,delete,insert,update on ref_owner.test_online_ref to ref_conn; 然后在连接用户创建同义词。 ##connect account: ref_conn conn ref_conn/oracle create synonym ref_conn.test_online_ref for ref_owner.test_online_ref; select count(*)from ref_conn.test_online_ref; 然后创建变更后的表。表结构信息可以根据需求来定义改变,比如从改一个普通表变为分区表。 conn ref_owner/oracle CREATE TABLE new_ref ( col1 varchar2(30), col2 DATE ) partition BY range(col2) ( partition tab_part_1 VALUES less than (to_date('2016-10-01','yyyy-mm-dd')), partition tab_part_2 VALUES less than (to_date('2017-10-01','yyyy-mm-dd')), partition tab_part_3 VALUES less than (to_date('2018-10-01','yyyy-mm-dd')), partition tab_part_4 VALUES less than (to_date('2019-10-01','yyyy-mm-dd')), partition tab_part_maxvalue values less than (maxvalue) );
grant select,delete on ref_owner.new_ref to ref_conn;
在线重定义的过程中,我们会并发调用开始所说的3个脚本来调用。然后观察是否会存在ORA的错误。 第一个场景的脚本如下: function test_conn { sqlplus -s ref_conn/oracle < set feedback off set time on col systimestamp format a35 select systimestamp,count(*)from test_online_ref; EOF }
for i in {1..1000000} do test_conn done
剩下两个场景的脚本,套路都是类似的,通过频繁的DML或者查询来完成 比如查询 select systimestamp,count(*)from test_online_ref; 比如DML delete from test_online_ref where rownum<2; commit;