PostgreSQL Database Import and Export

Source: Internet
Author: User
Tags psql import database

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:
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 export;

-h specifies the database address;

-u Specifies the database user;

-p Specifies the access port;

-f specifies export to file;

2. Export all table structures and data to file Monitor.sql from the database monitor on the remote database IP:
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, simply export all the table structures to the file Monitor.sql:
Pg_dump-s-H 135.32.94.142 monitor-u monitor-p 5432  

-S export table structure only

Note: The general database data volume is large, if the remote export all the table structure and data will be very slow, all the only export table structure is a wise choice. You can then 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:
Psql-h 135.32.9.99-d monitor-u monitor-f threshold.sql

-h specifies the database address;

-D Specify the database;

-U designated user;

-f Specifies the file to import (here is the file exported in step 1);

Note: The file here is the file exported from the remote database above.

2. Import to the local database:
Psql-h 0.0.0.0  
-p Specifies the database service port, which varies according to the local condition and is 5432 port by default


PostgreSQL Database Import and Export

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.