資料中臺 資料遷移相關指令碼

2022-03-31 05:41:49 字數 4024 閱讀 1004

1.資料準備

表資料

create table ecp_tables as select * from all_tab_comments where owner='bidpro' order by table_name;
字段資料

create table ecp_columns as

select b1.owner as owner2,

b1.table_name as table_name2, --"表名",

b1.column_name as column_name2, --"欄位名",

b1.data_type as data_type,--"字段型別「

a1.comments as comments2 ,--"字段說明"

b1.column_id as column_id --"字段序號"

from all_col_comments a1, all_tab_columns b1

where a1.owner in ('bidpro')

--改為後台資料庫使用者名稱

and a1.owner = b1.owner

and a1.table_name = b1.table_name

and a1.column_name = b1.column_name

order by b1.owner, b1.table_name, b1.column_id;

部分資料處理

create table ecp_tables_679 as 

select * from ecp_tables t where t.table_name in (select table_name from ecp_679);

create table ecp_columns_679 as

select * from ecp_columns t where t.table_name2 in (select table_name from ecp_679);

mysql 建表語句

create table erp_tables

( id int auto_increment,

owner varchar(200) ,

table_name varchar(200) ,

table_type varchar(100),

comments varchar(4000),

primary key (`id`)

);create table erp_columns (

id int auto_increment,

owner2 varchar ( 30 ) not null,

table_name2 varchar ( 30 ) not null,

column_name2 varchar ( 30 ) not null,

data_type varchar ( 106 ),

comments2 varchar ( 4000 ),

column_id int,

primary key ( `id` )

)

測試準備

抽取程序

select q'[table bidpro.]'||t.table_name||q'[,tokens (tkn-rowid=@getenv('record','rowid'));]' from user_tables  t order by table_name;
投遞程序

select q'[table bidpro.]'||t.table_name||';'  from user_tables  t order by table_name;
新增表級別的日誌

select q'[add trandata bidpro.]'||t.table_name from user_tables  t order by table_name;
新增抽取程序

add extract ext_dh02,tranlog,begin now

add exttrail ./dirdat/dp, extract ext_dh02

新增投遞程序(特別注意add rmttrail /oggadapter/dirdat/dp, 這一步是目標端的位址,不是源端的)

add extract dp_dh02,exttrailsource ./dirdat/dp

add rmttrail /oggadapter/dirdat/dp,extract dp_dh02

合併指令碼1

select  t2.*

from (

select ext_rowid

,max(ext_date_time) as maxdate

from ods_ogg_ecp1_ebiz_bidpro_bid_task_filedetail

where ds > - 1

group by ext_rowid

) t1

,ods_ogg_ecp1_ebiz_bidpro_bid_task_filedetail t2

where t1.ext_rowid = t2.ext_rowid

and t1.maxdate = t2.ext_date_time

and t2.ext_flag <> 'd'

and t2.ds > - 1

;

select t1.* from  (select  t.*

,row_number() over(partition by ext_rowid order by ext_ogg_seq desc) as rownumber

from ods_ogg_ecp1_ebiz_bidpro_bid_task_filedetail t where ds>-1 ) t1 where t1.rownumber='1' and t1.ext_flag <>'d'

;

select * from  erp_tables; --2772 +23=2795

create table erp_cd_ogg(num_seq number,table_name varchar2(100),ogg_pump varchar2(100),trial varchar2(10));

select table_name from erp_tables minus select * from erp_cd_0419_2796;

select * from erp_cd_0419_2796 minus select table_name from erp_cd_ogg;

select distinct t.data_type from dba_tab_columns t;

create table erp_tables_23 as select * from erp_tables where 1=0;

create table erp_tables_2796_ogg as select t1.*,t2.num_seq,t2.ogg_pump,t2.trial from erp_tables_2796 t1, erp_cd_ogg t2 where t1.table_name=t2.table_name order by t2.trial,t2.num_seq ;

select * from erp_cd_ogg;

create table erp_tables_0420_2639_ogg as  select t1.*,t2.num_seq,t2.ogg_pump,t2.trial from erp_cd_0420_2639 t1, erp_cd_ogg t2 

where t1.table_name=t2.table_name order by t2.trial,t2.num_seq ;

資料中臺 資料倉儲 大資料平台

資料中颱是一套可持續 讓企業的資料用起來 的機制,一種戰略選擇和組織形式,是依據企業特有的業務模式和組織架構,通過有形的產品和實施方 支撐,構建一套持續不斷把資料變成資產並服務於業務的機制。資料中臺 資料倉儲 大資料平台的關鍵區別是什麼?認可了資料中颱的價值,我們自然是想要去快速搭建,然後真正去規劃...

python資料庫遷移指令碼

usr bin env python coding utf 8 import json from sqlalchemy import engine create engine postgresql metadata metadata engine t batch copy表示新版的批次表 t bat...

oracle簡單資料遷移指令碼

bin bash function history export extfile date y m d h m export bak dir home oracle data bak su oracle c exp user01 user01 file bak dir user01.extfile....