项目上的一张大表tab_user_info,有将近千万级别的数据,现在需要数据迁移,然后进行分表操作,分10张表,分别存储部分数据。现在通过演练实现以上的操作
1、创建表
create table tab_user_info (
userid int ,
username varchar2(100),
moblie varchar2(100),
regist_time date,
insert_date date
);
2、循环插入1000万条数据
declare
i number;
begin
i := 0;
for i in 1 .. 10000000 loop
insert into tab_user_info
select trunc(f_get_random_str(6)),f_get_sys_guid(),f_get_mobile_num(),f_get_rounddate('20200101','20231231'),
f_get_rounddate('20200101','20231231') from dual;
if mod(i,10000) =0 then
commit;
end if;
end loop;
end;
3、创建十张表
--创建10张表,把tab_user_info的数据分表插入不同的表,根据userid
create table tab_user_info_00
as
select * from tab_user_info where 1=2;
create table tab_user_info_