当前位置:网站首页>Shell script import and export data
Shell script import and export data
2022-07-03 15:35:00 【crysw】
1. Introduce
At work , Many scenes will involve db Import and export of data , In order not to affect normal business , Generally, you will choose to run a batch of scheduled tasks to import and export data when the number of transaction visits at night is small . Our company , Because it is divided into development centers in different regions , There are also many application systems , Therefore, the data dependence between the systems with interconnected businesses , We are Data center Do data transfer , such as : A The system needs to operate the customer information, but it doesn't have this part of information , Customer information is mainly B The system is under maintenance , Now A The system needs B Data of the system .
The plan is B The system publishes customer information and data resources to Data center , because A System to Data center Subscribe to the B Customer information resources of the system , Data center Will forward customer information resources to A The specified directory of the system server , Last A The system only needs to be developed shell The script can import the data in the resource file into the local database .
B System needs A The same is true of the business data of the system , A The system only needs to publish business data resources to Data center ,(A The system development script will db The data is exported as a data file and sent to the data center ), B System subscription A System resources , from Data center Do resource forwarding .
The following is a summary of the work used shell How the script implements db Data import and export , Data center It is an enterprise level data exchange service platform , I won't go into details here .
2. Import data to db2
take MY_CUSTOMER_INFO_[DATE].del File data import MY_CUSTOMER_INFO surface .
3. export db2 data
take MY_CUSTOMER_INFO The data of the table is exported as MY_CUSTOMER_INFO_[DATE].del file .
Exporting data can also use java The program first queries the data , And then through IO Streaming file .
4. Import data to mysql
take MY_CUSTOMER_INFO_[DATE].del File data import MY_CUSTOMER_INFO surface .
Import data section , If null The data wants to be replaced by an empty string , have access to NULLIF Replace after function judgment .
5. export mysql data
take MY_CUSTOMER_INFO The data of the table is exported as MY_CUSTOMER_INFO_[DATE].del file .
6. Java Program call shell Script
Use java.lang.Runtime Class implementation shell Call and execute the script .
7. Problems encountered
(1) above Java The program calls and executes shell Script , Note that the server system type is Linux still AIX System , Otherwise, the incoming parameters cannot be received .
(2) windows Environmental Science (\r\n) and linux Environmental Science (\r) The line breaks are different , Lead to in windows Edited by the system shell Script in Linux An error is reported on the server , Need to use vim The editor will \r\n Replace with \r.
Script formatting , \r\n Replace with \r.
:set ff=unix
Script formatting , \r Replace with \r\n.
:set ff=dos
边栏推荐
- Using multipleoutputs to output multiple files in MapReduce
- 从 flask 服务端代码自动生成客户端代码 -- flask-native-stubs 库介绍
- C语言刷题~Leetcode与牛客网简单题
- Unityshader - materialcapture material capture effect (Emerald axe)
- Backtracking method to solve batch job scheduling problem
- Tensorflow realizes verification code recognition (I)
- Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
- WinDbg分析dump文件
- Second kill system 3 - list of items and item details
- Kubernetes will show you from beginning to end
猜你喜欢

App移动端测试【3】ADB命令

Redis lock Optimization Practice issued by gaobingfa

使用AUR下载并安装常用程序

Vs2017 is driven by IP debugging (dual machine debugging)

Seckill system 3- product list and product details

Can‘t connect to MySQL server on ‘localhost‘

Secsha system 1- login function
![[cloud native training camp] module VIII kubernetes life cycle management and service discovery](/img/87/92638402820b32a15383f19f6f8b91.png)
[cloud native training camp] module VIII kubernetes life cycle management and service discovery

Dataframe returns the whole row according to the value

Wechat payment -jsapi: code implementation (payment asynchronous callback, Chinese parameter solution)
随机推荐
Go语言自学系列 | golang中的if else语句
App移动端测试【4】apk的操纵
The state does not change after the assignment of El switch
Using Tengine to solve the session problem of load balancing
[combinatorial mathematics] binomial theorem and combinatorial identity (binomial theorem | three combinatorial identities | recursive formula 1 | recursive formula 2 | recursive formula 3 Pascal / Ya
Microservice API gateway zuul
UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
软件安装信息、系统服务在注册表中的位置
Kubernetes vous emmène du début à la fin
Popular understanding of decision tree ID3
The difference between RAR and zip files
秒殺系統3-商品列錶和商品詳情
秒杀系统3-商品列表和商品详情
CString的GetBuffer和ReleaseBuffer使用说明
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
Popular understanding of random forest
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
The wonderful use of do{}while()
Srs4.0+obs studio+vlc3 (environment construction and basic use demonstration)
视觉上位系统设计开发(halcon-winform)-1.流程节点设计