当前位置:网站首页>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
边栏推荐
- [probably the most complete in Chinese] pushgateway entry notes
- Puppet automatic operation and maintenance troubleshooting cases
- Construction of operation and maintenance system
- Srs4.0+obs studio+vlc3 (environment construction and basic use demonstration)
- The difference between RAR and zip files
- Subclass hides the function with the same name of the parent class
- 【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
- The wonderful use of do{}while()
- 《微服务设计》读书笔记(下)
- SQL server installation location cannot be changed
猜你喜欢
Jvm-08-garbage collector
Microservice - declarative interface call openfeign
秒杀系统2-Redis解决分布式Session问题
Srs4.0+obs studio+vlc3 (environment construction and basic use demonstration)
Microservice - fuse hystrix
VS2017通过IP调试驱动(双机调试)
UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
Basic SQL tutorial
百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
Creation and destruction of function stack frames
随机推荐
Popular understanding of linear regression (II)
Vs2017 is driven by IP debugging (dual machine debugging)
详解指针进阶2
Popular understanding of linear regression (I)
CString中使用百分号
Unity功能——Unity离线文档下载及使用
求字符串函数和长度不受限制的字符串函数的详解
Tensorflow realizes verification code recognition (III)
Go语言自学系列 | golang中的if else if语句
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
qt使用QZxing生成二维码
Halcon and WinForm study section 1
Redis在Windows以及Linux系统下的安装
Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
App移动端测试【3】ADB命令
Visual upper system design and development (Halcon WinForm) -3 Image control
子类隐藏父类的同名函数
Creation and destruction of function stack frames
CString getbuffer and releasebuffer instructions
App mobile terminal test [5] file writing and reading