当前位置:网站首页>PGSQL database to realize the import and export
PGSQL database to realize the import and export
2022-08-02 12:33:00 【m0_67400972】
pgsql database import and export
1. Export table
pg_dump -h database ip -U username database name -t table name >path, for example:
pg_dump -h 127.0.0.1 -U sysdba data_center -t book >/data/book.sql
2. Import table
psql -U username -d database name pg_dump -h database ip -U username database name>Path, for example: psql -U username database name When the exported data is very large, you should use the xz compression command, which generates a file with a suffix of .xz, for example: The data_center.sql.xz file will be generated at this time xzcat compressed file path | psql -h database ip -U username database name, for example: pg_restore -h ip -U username -d database name -v file path, for example: Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materialspsql -U sysdba -d data_center
3. Export database
pg_dump -h 127.0.0.1 -U sysdba data_center >/data/data_center.sql
4. Import database
psql -U sysdba data_center
5. Compression
xz data_center.sql
6. Import the compressed file into the database
xzcat /data/data_center.sql.xz | psql -h 127.0.0.1 -U sysdba data_center
7. pgsql restores files in the database (import dmp files)
pg_restore -h 127.0.0.1 -U sysdba -d sjls -v /usr/postgres.dmp
边栏推荐
猜你喜欢
随机推荐
SQL Server database generation and execution of SQL scripts
SQL Server 2014安装教程(保姆级图解教程)
30行代码实现无服务器实时健康码识别--操作手册
To eliminate air bubbles to save the mushroom h5 small game source code
Data Lake (2): What is Hudi
Drools(8):WorkBench使用
The ex-boyfriend bought chili water and threatened to rob his daughter. Can the woman apply for a personal safety protection order?
openGauss数据库基本操作(超详细)
Custom mvc framework review
MD5详解(校验文件完整性)
WebUI自动化测试框架搭建从0到1(完整源码)更新完毕
太厉害了,终于有人能把TCP/IP 协议讲的明明白白了
LeetCode_139_单词拆分
np.nan, np.isnan, None, pd.isnull, pd.isna 整理与小结
js true 3d histogram plugin
MD5 detailed explanation (check file integrity)
A powerful js pop-up alert plugin
Chapter 14 Manually create a REST service (2)
Intouch Historian历史曲线配置导入导出
js炫酷仪表盘插件