Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PostgresSQL export data

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Recently, we need to export postgres to the data file, but it is not successful to use pgAdmin for a long time. Finally, we use the command of postgre to export the sql file. The operation is as follows: enter the bin directory of the postgres installation directory, such as windows: C:\ Program Files\ PostgreSQL\ 10\ bin, and execute the pg_dump command: 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) plaintext (default)-v,-- verbose detail mode-V,-- version output version information Then exit the compression level of-Z,-- compress=0-9 compressed format-- lock-wait-timeout=TIMEOUT failed after waiting for the table lock timeout-help displays this help, and then exit the control output option:-a,-- data-only only dumps data, excluding mode-b -- blobs includes large objects in the dump-c,-- clean before re-creating First clear (delete) the database object-C,-- create includes commands in the dump to create the database-E,-- encoding=ENCODING dump data encoded in ENCODING form-n,-- schema=SCHEMA only dumps the schema of the specified name-N,-- exclude-schema=SCHEMA does not dump the named schema-o -- oids includes OID-O in the dump,-- no-owner ignores the owner of the recovery object in plaintext format-s,-- schema-only only dumps mode, does not include data-S,-- superuser=NAME uses the specified super user name-t in plaintext format -- table=TABLE only dumps tables with specified names-T,-- exclude-table=TABLE does not dump tables with specified names-x -- no-privileges do not dump permissions (grant/revoke)-- binary-upgrade can only be used by upgrade tools-- column-inserts dumps data in the form of an INSERT command with column names-- disable-dollar-quoting cancels dollar (symbol) quotation marks Use SQL standard quotes-- disable-triggers disables triggers during data recovery only-- exclude-table-data=TABLE does not dump data in a table with the specified name-- inserts with the INSERT command Instead of dumping data in the form of the COPY command-- no-security-labels does not dump the allocation of security labels-- no-tablespaces does not dump tablespace allocation information-- no-unlogged-table-data does not dump table data without logs-- all quote-all-identifiers identifiers are quoted. Even if it is not a keyword-- section=SECTION backup named sections (before, after, and after data)-- serializable-deferrable waits until the backup can run without exception-- use-set-session-authorization uses the SESSION AUTHORIZATION command instead of the ALTER OWNER command to set the ownership join option:-h -- host= hostname database server hostname or socket directory-- p,-- port= port number database server port number-U,-- username= name to connect to the specified database user-w,-- no-password never prompts for a password-W -- password mandatory password prompt (automatic)-- role=ROLENAME runs SET ROLE before dump author: programmers who do not have to work overtime link: https://www.jianshu.com/p/6b064c2ccf91 source: the copyright of the short book belongs to the author For any form of reprint, please contact the author for authorization and indicate the source. Import and export sql data one. Export database and specific table 1. Export database: method 1: pg_dump-U postgres-f c:\ db.sql postgis method 2: pg_dump-U postgres postgis > c:\ db.sql2. Import database: method 1: psql-d postgis-f c:\ db.sql postgres3. Export the specific table: method 1: pg_dump-Upostgres-t mytable-f dump.sql postgres4. Import specific table: method 1: psql-d postgis-f c:\ dump.sql postgres parameters: postgres: user postgis: database name mytable: table name-f,-- file= file name: output file name-U,-- username= name: join II with the specified database user. Export data format detailed usage: pg_dump [options]. [database name] General options:-f,-- file= file name output file name-F,-- format=c | t | p output file format (custom, tar, plaintext)-v,-- verbose detailed mode-Z -- compression level of compress=0-9 compressed format-- lock-wait-timeout=TIMEOUT failed after waiting for table lock timeout-- help displays this help information, then exits-- versoin outputs version information, and then exits control output content option:-a,-- data-only only dumps data, excluding mode-b -- blobs includes large objects in the dump-c,-- clean before re-creating First clear (delete) the database object-C,-- create includes commands in the dump to create the database-E,-- encoding=ENCODING dump data encoded in the form of ENCODING-n,-- schema=SCHEMA only dumps the schema of the specified name-- NQuinghyu schema does not dump the named schema-o,-- oids includes OID-O in the dump. -- no-owner ignores the owner of the recovery object in plaintext format-s,-- schema-only only dumps mode, excluding data-S,-- superuser=NAME in the dump, the specified super user name-t,-- table=TABLE only dumps the specified name table-T,-- exclude-table=TABLE only dumps the specified name table-x -- no-privileges do not dump permissions (grant/revoke)-- binary-upgrade can only be used by the upgrade tool-- inserts with the INSERT command Instead of dumping data in the form of a COPY command-- column-inserts dumps data in the form of an INSERT command with column names-- disable-dollar-quoting cancels dollar (symbol) quotation marks Use SQL standard quotes-disable-triggers disables triggers during data recovery only-no-tablespaces does not dump tablespace allocation information-role=ROLENAME runs SETROLE before dump-use-set-session-authorization uses the SESSION AUTHORIZATION command instead of the ALTER OWNER command to set the ownership join option:-h -- host= hostname database server hostname or socket directory-- p,-- port= port number database server port number-U,-- username= name to connect to the specified database user-w,-- no-password never prompts for a password-W,-- password mandatory password prompt (automatic)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report