当前位置:网站首页>pgsql数据库实现导入导出
pgsql数据库实现导入导出
2022-08-02 12:18:00 【m0_67400972】
pgsql数据库实现导入导出
1.导出表
pg_dump -h 数据库ip -U 用户名 数据库名 -t 表名 >路径,例:
pg_dump -h 127.0.0.1 -U sysdba data_center -t book >/data/book.sql
2.导入表
psql -U 用户名 -d 数据库名 <路径,例:
psql -U sysdba -d data_center </data/book.sql
3.导出数据库
pg_dump -h 数据库ip -U 用户名 数据库名 >路径,例:
pg_dump -h 127.0.0.1 -U sysdba data_center >/data/data_center.sql
4.导入数据库
psql -U 用户名 数据库名 <路径,例:
psql -U sysdba data_center </data/data_center.sql
5.压缩
当导出的数据很大时,应使用xz压缩命令,该命令生成后缀为.xz的文件,例:
xz data_center.sql
此时会生成data_center.sql.xz文件
6.压缩文件导入数据库
xzcat 压缩文件路径 | psql -h 数据库ip -U 用户名 数据库名,例:
xzcat /data/data_center.sql.xz | psql -h 127.0.0.1 -U sysdba data_center
7. pgsql恢复数据库中的文件(导入dmp文件)
pg_restore -h ip -U 用户名 -d 数据库名 -v 文件路径,例:
pg_restore -h 127.0.0.1 -U sysdba -d sjls -v /usr/postgres.dmp
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- Running yum reports Error: Cannot retrieve metalink for reposit
- Metaverse "Drummer" Unity: Crazy expansion, suspense still exists
- Seneor曝光基础知识
- sql concat()函数
- QListView的使用
- 测试开发之路,我在大厂做测试这四年的感悟
- Create a devops CI/CD process using the kubesphere GUI
- #Summer Challenge#[FFH] OpenHarmony Device Development Foundation (3) Compilation Dependencies
- 阿苹的思考
- How to connect TDengine through DBeaver?
猜你喜欢

免费的中英文翻译软件-自动批量中英文翻译软件推荐大全

Likou 209 - String with the Minimum Length - Sliding Window Method

喜迎八一 《社会企业开展应聘文职人员培训规范》团体标准出版发行会暨橄榄枝大课堂上线发布会在北京举行

Free Chinese-English Translation Software - Automatic Batch Chinese-English Translation Software Recommended Daquan

技术分享| 融合调度系统中的电子围栏功能说明

Problem solving in the process of using mosquitto

Create an application operation process using the kubesphere GUI

When not to use () instead of Void in Swift

CCF paper conference IEEE how to query all articles of a conference journal

unique in numpy & pandas
随机推荐
第11章 文件
【第六届强网杯CTF-Wp】
QListView的使用
SQL Server2019安装步骤及脱机安装Microsoft机器学习组件下一步不能继续的问题
Create an application operation process using the kubesphere GUI
AQS-AbstractQueuedSynchronizer
Create a devops CI/CD process using the kubesphere GUI
MySQL主从复制几个重要的启动选项
Likou 35 - search for insertion position - binary search
Speed up your programs with bitwise operations
【Acunetix-Forgot your password】
Crack detection technology based on deep learning
SQL Server如何建表
借小程序容器打造自有App小程序生态
翻译英语的软件-免费翻译软件-各种语言互相翻译
手撸架构,MongDB 面试50问
力扣35-搜索插入位置——二分查找
网站自动翻译-网站批量自动翻译-网站免费翻译导出
An example of type3 voltage loop compensator taking Boost as an example
Solve the problem of Chinese garbled characters in exporting excel file names