Postgresql database import and export, postgresql Import and Export

Source: Internet
Author: User
Tags psql import database

Postgresql database import and export, postgresql Import and Export
Export a remote database

1. Export the threshold table structure and data to the file threshold. SQL from the database monitor on the remote database IP Address:
pg_dump -t threshold -h 135.32.94.142 monitor -U monitor -p 5432  -f threshold.sql

-T specifies the name of the table to be exported;

-H: Specifies the database address;

-U indicates the database user;

-P specifies the access port;

-F specifies the file to be exported;

2. Export all table structures and data from the database monitor on the remote database IP address to the File monitor. SQL:
pg_dump -h 135.32.94.142 monitor -U monitor -p 5432  -f monitor.sql

3. From the database monitor on the remote database IP address, only all the table structures are exported to the File monitor. SQL:
pg_dump -s -h 135.32.94.142 monitor -U monitor -p 5432  -f monitor.sql 

-S: only export the table structure

Note: Generally, the database data volume is relatively large. If you remotely export all the table structures and data, it will be very slow. It is a wise choice to export only the table structure. Then you can export the structure and data of a single important data table. Import database 1. Import the table structure and data from the local file threshold. SQL to the database monitor on the remote IP Address:
psql -h 135.32.9.99 -d monitor -U monitor -f threshold.sql

-H: Specifies the database address;

-D specifies the database;

-U indicates the user;

-F specifies the file to be imported (here is the file exported in step 1 );

Note: The files here are the files exported from the remote database.

2. Import to local database:
psql -h 0.0.0.0  -p 5432 -d monitor -U monitor -f monitor.sql 
-P: Specifies the Database Service port, which is changed based on local conditions. The default value is port 5432.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.