更新
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
### 数据库导出
|
||||
## 数据库导出
|
||||
|
||||
#### 链接信息
|
||||
|
||||
@ -365,10 +365,6 @@ pattern参数
|
||||
|
||||
|
||||
|
||||
#### psql
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### pg_restore
|
||||
@ -628,10 +624,14 @@ psql -Uicctestedb -dicctestedb -h192.168.53.123 -f ~/
|
||||
|
||||
|
||||
|
||||
### 实操数据导入导出
|
||||
|
||||
### 整库导出
|
||||
|
||||
使用 pg_dump 与 pg_restore 完成数据转移,适合整表 整库 迁移
|
||||
|
||||
#### 数据导出
|
||||
|
||||
|
||||
|
||||
```shell
|
||||
#导出 iccedb库
|
||||
# -O 不设置表归属,
|
||||
@ -651,8 +651,10 @@ psql -Uicctestedb -dicctestedb -h192.168.53.123 -f ~/
|
||||
#-c 指定恢复过程中清空目标数据库中的现有表
|
||||
#--strict-names 指定严格遵守输入文件中的名称规范
|
||||
#~/icc_data_20220719_test.sql 指定要恢复的输入文件路径
|
||||
#-n revenue_mgt 恢复 revenue_mgt schema
|
||||
#-j 4 并行化操作
|
||||
|
||||
./pg_restore -Uenterprisedb -dtest2 -h10.23.101.119 -F c -c -v --strict-names ~/icc_data_20220719_test.sql
|
||||
./pg_restore -Uenterprisedb -dtest2 -h10.23.101.119 -j4 -nrevenue_mgt -F c -c -v --strict-names ~/icc_data_20220719_test.sql
|
||||
```
|
||||
|
||||
|
||||
@ -663,21 +665,23 @@ psql -Uicctestedb -dicctestedb -h192.168.53.123 -f ~/
|
||||
|
||||
|
||||
|
||||
#### COPY 导出导出部分数据
|
||||
### 部分数据导出
|
||||
|
||||
COPY
|
||||
|
||||
```sh
|
||||
sudo su - enterprisedb
|
||||
psql edb
|
||||
```
|
||||
|
||||
##### 导出
|
||||
#### COPY 导出
|
||||
|
||||
```sql
|
||||
COPY (select * from icc.tcn_stat
|
||||
where afferent_date between to_date('20220701','yyyymmdd') and to_date('20220714','yyyymmdd') ) TO '/home/edbdata/test.csv' WITH csv;
|
||||
```
|
||||
|
||||
##### 导入
|
||||
#### COPY 导入
|
||||
|
||||
```sql
|
||||
COPY tcn_stat_sales_volume_total FROM '/home/edbdata/tcn_stat_sales_volume_total.csv' WITH csv;
|
||||
|
Reference in New Issue
Block a user