PostgreSQL Database Import and Export

Source: Internet
Author: User
Tags psql

Export the database data1 to a file in the shell with Command pg_dump

pg_dump-d data1-f Test.txt

Or

pg_dump-d data1 > Test.sql

And then create an empty library

Createdb  data2

Import data1 data into data2 with the Psql command

psql-d data2-D data2 < Test.sql

Pg_dump More information

Pg_dump dumps a database into plain text files or other formats.
Usage: pg_dump [options] ... [Database name]
General Options:
-F,--file=filename output file or directory name
-F,--format=c|d|t|p output file format (custom, directory, tar, plain text)
-V,--verbose verbose mode
-Z,--compress=0-9 compression level in compressed format
--lock-wait-timeout=timeout operation failed after waiting for table lock timeout
--HELP Display this help message, and then exit
--versoin output version information, and then exit
Control output Content options:
-A,--data-only only dumps data, not including mode
-B,--blobs include large objects in the dump
-C,--clean Clear (delete) database objects before re-creation
-C,--create includes commands in the dump to create the database
-E,--encoding=encoding dumps data encoded in encoding form
-N,--schema=schema only dumps the pattern of the specified name
-N,--exclude-schema=schema does not dump the named pattern
-O,--oids include OID in dump
-O,--no-owner in clear text format, ignores the owner of the recovery object
-S,--schema-only only dump mode, excluding data
-S,--superuser=name in the dump, the specified super user name
-T,--table=table only dump tables with the specified name
-T,--exclude-table=table only dump tables with the specified name
-X,--no-privileges do not dump permissions (Grant/revoke)
--binary-upgrade can only be used by the upgrade tool
--column-inserts dump data as an insert command with a column name
--disable-dollar-quoting Canceling dollar (sign) quotes, using SQL standard quotes
--disable-triggers disabling triggers during data recovery only
--inserts dump data as an insert command, not as a copy command
--no-security-labels do not dump security label assignments
--no-tablespaces No dump table space allocation information
--no-unlogged-table-data do not dump unlogged table data
--quote-all-identifiers quote All identifiers, even if not key words
--serializable-deferrable wait until the dump can run without anomalies
--use-set-session-authorization
Use the SESSION AUTHORIZATION command instead of the alter OWNER command to set ownership
Join options:
-H, host name or socket directory for the--host= hostname database server
-P,--port= port number of the database server
-U,--username= names are joined with the specified database user
-W,--no-password never prompt to enter a password
-W,--password mandatory password prompt (automatic)
--role=rolename do SET role before dump
If the database name is not provided, the value of the PGDATABASE environment variable is used.

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.