⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pg_dump.1

📁 PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开发团队说,该版本将加速更多企业向该数据库移植.核心开发成员之一Bruce Momjian表示,在新版PostgreSQL
💻 1
📖 第 1 页 / 共 2 页
字号:
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "PG_DUMP" "1" "2008-01-03" "Application" "PostgreSQL Client Applications".SH NAMEpg_dump \- extract a PostgreSQL database into a script file or other archive file.SH SYNOPSIS.sp\fBpg_dump\fR [ \fB\fIoption\fB\fR\fI...\fR ]  [ \fB\fIdbname\fB\fR ] .SH "DESCRIPTION".PP\fBpg_dump\fR is a utility for backing up aPostgreSQL database. It makes consistentbackups even if the database is being used concurrently.\fBpg_dump\fR does not block other usersaccessing the database (readers or writers)..PPDumps can be output in script or archive file formats. Scriptdumps are plain-text files containing the SQL commands requiredto reconstruct the database to the state it was in at the time it wassaved. To restore from such a script, feed it to \fBpsql\fR(1). Script filescan be used to reconstruct the database even on other machines andother architectures; with some modifications even on other SQLdatabase products..PPThe alternative archive file formats must be used with\fBpg_restore\fR(1) to rebuild the database. Theyallow \fBpg_restore\fR to be selective aboutwhat is restored, or even to reorder the items prior to beingrestored.The archive file formats are designed to be portable acrossarchitectures..PPWhen used with one of the archive file formats and combined with\fBpg_restore\fR,\fBpg_dump\fR provides a flexible archival andtransfer mechanism. \fBpg_dump\fR can be used tobackup an entire database, then \fBpg_restore\fRcan be used to examine the archive and/or select which parts of thedatabase are to be restored. The most flexible output file format isthe ``custom'' format (\fB-Fc\fR). It allowsfor selection and reordering of all archived items, and is compressedby default. The \fBtar\fR format(\fB-Ft\fR) is not compressed and it is not possible toreorder data when loading, but it is otherwise quite flexible;moreover, it can be manipulated with standard Unix tools such as\fBtar\fR..PPWhile running \fBpg_dump\fR, one should examine theoutput for any warnings (printed on standard error), especially inlight of the limitations listed below..SH "OPTIONS".PPThe following command-line options control the content andformat of the output..TP\fB\fIdbname\fB\fRSpecifies the name of the database to be dumped. If this isnot specified, the environment variable\fBPGDATABASE\fR is used. If that is not set, theuser name specified for the connection is used..TP\fB-a\fR.TP\fB--data-only\fRDump only the data, not the schema (data definitions).This option is only meaningful for the plain-text format. Forthe archive formats, you may specify the option when youcall \fBpg_restore\fR..TP\fB-b\fR.TP\fB--blobs\fRInclude large objects in the dump. This is the default behaviorexcept when \fB--schema\fR, \fB--table\fR, or\fB--schema-only\fR is specified, so the \fB-b\fRswitch is only useful to add large objects to selective dumps..TP\fB-c\fR.TP\fB--clean\fROutput commands to clean (drop)database objects prior to (the commands for) creating them.This option is only meaningful for the plain-text format. Forthe archive formats, you may specify the option when youcall \fBpg_restore\fR..TP\fB-C\fR.TP\fB--create\fRBegin the output with a command to create thedatabase itself and reconnect to the created database. (With ascript of this form, it doesn't matter which database you connectto before running the script.)This option is only meaningful for the plain-text format. Forthe archive formats, you may specify the option when youcall \fBpg_restore\fR..TP\fB-d\fR.TP\fB--inserts\fRDump data as \fBINSERT\fR commands (ratherthan \fBCOPY\fR). This will make restoration very slow;it is mainly useful for making dumps that can be loaded intonon-PostgreSQL databases.Also, since this option generates a separate command for each row,an error in reloading a row causes only that row to be lost ratherthan the entire table contents.Note thatthe restore may fail altogether if you have rearranged column order.The \fB-D\fR option is safe against column order changes,though even slower..TP\fB-D\fR.TP\fB--column-inserts\fR.TP\fB--attribute-inserts\fRDump data as \fBINSERT\fR commands with explicitcolumn names (INSERT INTO\fItable\fR(\fIcolumn\fR, ...) VALUES\&...). This will make restoration very slow; it is mainlyuseful for making dumps that can be loaded intonon-PostgreSQL databases.Also, since this option generates a separate command for each row,an error in reloading a row causes only that row to be lost ratherthan the entire table contents..TP\fB-E \fIencoding\fB\fR.TP\fB--encoding=\fIencoding\fB\fRCreate the dump in the specified character set encoding. By default,the dump is created in the database encoding. (Another way to get thesame result is to set the \fBPGCLIENTENCODING\fR environmentvariable to the desired dump encoding.).TP\fB-f \fIfile\fB\fR.TP\fB--file=\fIfile\fB\fRSend output to the specified file. If this is omitted, thestandard output is used..TP\fB-F \fIformat\fB\fR.TP\fB--format=\fIformat\fB\fRSelects the format of the output.\fIformat\fR can be one of the following:.RS.TP\fBp\fR.TP\fBplain\fROutput a plain-text SQL script file (the default)..TP\fBc\fR.TP\fBcustom\fROutput a custom archive suitable for input into\fBpg_restore\fR. This is the most flexibleformat in that it allows reordering of loading data as wellas object definitions. This format is also compressed by default..TP\fBt\fR.TP\fBtar\fROutput a \fBtar\fR archive suitable for input into\fBpg_restore\fR. Using this archive formatallows reordering and/or exclusion of database objectsat the time the database is restored. It is also possible to limitwhich data is reloaded at restore time..RE.PP.TP\fB-i\fR.TP\fB--ignore-version\fRIgnore version mismatch between\fBpg_dump\fR and the database server.\fBpg_dump\fR can dump from servers runningprevious releases of PostgreSQL, but very oldversions are not supported anymore (currently, those prior to 7.0).Dumping from a server newer than \fBpg_dump\fRis likely not to work at all.Use this option if you need to override the version check (andif \fBpg_dump\fR then fails, don't sayyou weren't warned)..TP\fB-n \fIschema\fB\fR.TP\fB--schema=\fIschema\fB\fRDump only schemas matching \fIschema\fR; this selects both theschema itself, and all its contained objects. When this option isnot specified, all non-system schemas in the target database will bedumped. Multiple schemas can beselected by writing multiple \fB-n\fR switches. Also, the\fIschema\fR parameter isinterpreted as a pattern according to the same rules used by\fBpsql\fR's \\d commands (see Patterns [\fBpsql\fR(1)]),so multiple schemas can also be selected by writing wildcard charactersin the pattern. When using wildcards, be careful to quote the patternif needed to prevent the shell from expanding the wildcards..sp.RS.B "Note:"When \fB-n\fR is specified, \fBpg_dump\fRmakes no attempt to dump any other database objects that the selectedschema(s) may depend upon. Therefore, there is no guaranteethat the results of a specific-schema dump can be successfullyrestored by themselves into a clean database..RE.sp.sp.RS.B "Note:"Non-schema objects such as blobs are not dumped when \fB-n\fR isspecified. You can add blobs back to the dump with the\fB--blobs\fR switch..RE.sp.TP\fB-N \fIschema\fB\fR.TP\fB--exclude-schema=\fIschema\fB\fRDo not dump any schemas matching the \fIschema\fR pattern. The pattern isinterpreted according to the same rules as for \fB-n\fR.\fB-N\fR can be given more than once to exclude schemasmatching any of several patterns.When both \fB-n\fR and \fB-N\fR are given, the behavioris to dump just the schemas that match at least one \fB-n\fRswitch but no \fB-N\fR switches. If \fB-N\fR appearswithout \fB-n\fR, then schemas matching \fB-N\fR areexcluded from what is otherwise a normal dump..TP\fB-o\fR.TP\fB--oids\fRDump object identifiers (OIDs) as part of thedata for every table. Use this option if your application referencesthe OIDcolumns in some way (e.g., in a foreign key constraint).Otherwise, this option should not be used..TP\fB-O\fR.TP\fB--no-owner\fRDo not output commands to setownership of objects to match the original database.By default, \fBpg_dump\fR issues\fBALTER OWNER\fR or\fBSET SESSION AUTHORIZATION\fRstatements to set ownership of created database objects.These statementswill fail when the script is run unless it is started by a superuser(or the same user that owns all of the objects in the script).To make a script that can be restored by any user, but will givethat user ownership of all the objects, specify \fB-O\fR.This option is only meaningful for the plain-text format. Forthe archive formats, you may specify the option when youcall \fBpg_restore\fR..TP\fB-R\fR.TP\fB--no-reconnect\fRThis option is obsolete but still accepted for backwardscompatibility..TP\fB-s\fR.TP\fB--schema-only\fRDump only the object definitions (schema), not data..TP\fB-S \fIusername\fB\fR.TP\fB--superuser=\fIusername\fB\fRSpecify the superuser user name to use when disabling triggers.This is only relevant if \fB--disable-triggers\fR is used.(Usually, it's better to leave this out, and instead start theresulting script as superuser.).TP\fB-t \fItable\fB\fR.TP\fB--table=\fItable\fB\fRDump only tables (or views or sequences) matching \fItable\fR. Multiple tables can beselected by writing multiple \fB-t\fR switches. Also, the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -