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

📄 pg_dump.1

📁 PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开发团队说,该版本将加速更多企业向该数据库移植.核心开发成员之一Bruce Momjian表示,在新版PostgreSQL
💻 1
📖 第 1 页 / 共 2 页
字号:
\fItable\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 tables 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.The \fB-n\fR and \fB-N\fR switches have no effect when\fB-t\fR is used, because tables selected by \fB-t\fR willbe dumped regardless of those switches, and non-table objects will notbe dumped..sp.RS.B "Note:"When \fB-t\fR is specified, \fBpg_dump\fRmakes no attempt to dump any other database objects that the selectedtable(s) may depend upon. Therefore, there is no guaranteethat the results of a specific-table dump can be successfullyrestored by themselves into a clean database..RE.sp.sp.RS.B "Note:"The behavior of the \fB-t\fR switch is not entirely upwardcompatible with pre-8.2 PostgreSQLversions. Formerly, writing -t tab would dump alltables named tab, but now it just dumps whichever oneis visible in your default search path. To get the old behavioryou can write -t '*.tab'. Also, you must write somethinglike -t sch.tab to select a table in a particular schema,rather than the old locution of -n sch -t tab..RE.sp.TP\fB-T \fItable\fB\fR.TP\fB--exclude-table=\fItable\fB\fRDo not dump any tables matching the \fItable\fR pattern. The pattern isinterpreted according to the same rules as for \fB-t\fR.\fB-T\fR can be given more than once to exclude tablesmatching any of several patterns.When both \fB-t\fR and \fB-T\fR are given, the behavioris to dump just the tables that match at least one \fB-t\fRswitch but no \fB-T\fR switches. If \fB-T\fR appearswithout \fB-t\fR, then tables matching \fB-T\fR areexcluded from what is otherwise a normal dump..TP\fB-v\fR.TP\fB--verbose\fRSpecifies verbose mode. This will cause\fBpg_dump\fR to output detailed objectcomments and start/stop times to the dump file, and progressmessages to standard error..TP\fB-x\fR.TP\fB--no-privileges\fR.TP\fB--no-acl\fRPrevent dumping of access privileges (grant/revoke commands)..TP\fB--disable-dollar-quoting\fRThis option disables the use of dollar quoting for function bodies,and forces them to be quoted using SQL standard string syntax..TP\fB--disable-triggers\fRThis option is only relevant when creating a data-only dump.It instructs \fBpg_dump\fR to include commandsto temporarily disable triggers on the target tables whilethe data is reloaded. Use this if you have referentialintegrity checks or other triggers on the tables that youdo not want to invoke during data reload.Presently, the commands emitted for \fB--disable-triggers\fRmust be done as superuser. So, you should also specifya superuser name with \fB-S\fR, or preferably be careful tostart the resulting script as a superuser.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--use-set-session-authorization\fROutput SQL-standard \fBSET SESSION AUTHORIZATION\fR commandsinstead of \fBALTER OWNER\fR commands to determine objectownership. This makes the dump more standards compatible, butdepending on the history of the objects in the dump, may not restoreproperly. Also, a dump using \fBSET SESSION AUTHORIZATION\fRwill certainly require superuser privileges to restore correctly,whereas \fBALTER OWNER\fR requires lesser privileges..TP\fB-Z \fI0..9\fB\fR.TP\fB--compress=\fI0..9\fB\fRSpecify the compression level to use in archive formats thatsupport compression. (Currently only the custom archiveformat supports compression.).PP.PPThe following command-line options control the database connection parameters..TP\fB-h \fIhost\fB\fR.TP\fB--host=\fIhost\fB\fRSpecifies the host name of the machine on which the server isrunning. If the value begins with a slash, it is used as thedirectory for the Unix domain socket. The default is takenfrom the \fBPGHOST\fR environment variable, if set,else a Unix domain socket connection is attempted..TP\fB-p \fIport\fB\fR.TP\fB--port=\fIport\fB\fRSpecifies the TCP port or local Unix domain socket fileextension on which the server is listening for connections.Defaults to the \fBPGPORT\fR environment variable, ifset, or a compiled-in default..TP\fB-U \fIusername\fB\fRConnect as the given user.TP\fB-W\fRForce a password prompt. This should happen automatically ifthe server requires password authentication..PP.SH "ENVIRONMENT".TP\fBPGDATABASE\fR.TP\fBPGHOST\fR.TP\fBPGPORT\fR.TP\fBPGUSER\fRDefault connection parameters..PPThis utility, like most other PostgreSQL utilities,also uses the environment variables supported by \fBlibpq\fR(see in the documentation)..PP.SH "DIAGNOSTICS".PP\fBpg_dump\fR internally executes\fBSELECT\fR statements. If you have problems running\fBpg_dump\fR, make sure you are able toselect information from the database using, for example, \fBpsql\fR(1). Also, any default connection settings and environmentvariables used by the \fBlibpq\fR front-endlibrary will apply..SH "NOTES".PPIf your database cluster has any local additions to the template1 database,be careful to restore the output of \fBpg_dump\fR into atruly empty database; otherwise you are likely to get errors due toduplicate definitions of the added objects. To make an empty databasewithout any local additions, copy from template0 not template1,for example:.sp.nfCREATE DATABASE foo WITH TEMPLATE template0;.sp.fi.PP\fBpg_dump\fR has a few limitations:.TP 0.2i\(buWhen a data-only dump is chosen and the option\fB--disable-triggers\fR is used,\fBpg_dump\fR emits commands to disabletriggers on user tables before inserting the data and commandsto re-enable them after the data has been inserted. If therestore is stopped in the middle, the system catalogs may beleft in the wrong state..PP.PPMembers of tar archives are limited to a size less than 8 GB.(This is an inherent limitation of the tar file format.) Thereforethis format cannot be used if the textual representation of any one tableexceeds that size. The total size of a tar archive and any of theother output formats is not limited, except possibly by theoperating system..PPThe dump file produced by \fBpg_dump\fR doesnot contain the statistics used by the optimizer to make queryplanning decisions. Therefore, it is wise to run\fBANALYZE\fR after restoring from a dump file toensure good performance..PPBecause \fBpg_dump\fR is used to transfer datato newer versions of PostgreSQL, the output of\fBpg_dump\fR can be loaded intonewer PostgreSQL databases. It also can read olderPostgreSQL databases. However, it usually cannotread newer PostgreSQL databases or produce dump outputthat can be loaded into older database versions. To do this, manualediting of the dump file might be required..SH "EXAMPLES".PPTo dump a database called mydb into a SQL-script file:.sp.nf$ \fBpg_dump mydb > db.sql\fR.sp.fi.PPTo reload such a script into a (freshly created) database namednewdb:.sp.nf$ \fBpsql -d newdb -f db.sql\fR.sp.fi.PPTo dump a database into a custom-format archive file:.sp.nf$ \fBpg_dump -Fc mydb > db.dump\fR.sp.fi.PPTo reload an archive file into a (freshly created) database namednewdb:.sp.nf$ \fBpg_restore -d newdb db.dump\fR.sp.fi.PPTo dump a single table named mytab:.sp.nf$ \fBpg_dump -t mytab mydb > db.sql\fR.sp.fi.PPTo dump all tables whose names start with emp in thedetroit schema, except for the table namedemployee_log:.sp.nf$ \fBpg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql\fR.sp.fi.PPTo dump all schemas whose names start with east orwest and end in gsm, excluding any schemas whosenames contain the word test:.sp.nf$ \fBpg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb > db.sql\fR.sp.fi.PPThe same, using regular expression notation to consolidate the switches:.sp.nf$ \fBpg_dump -n '(east|west)*gsm' -N '*test*' mydb > db.sql\fR.sp.fi.PPTo dump all database objects except for tables whose names begin withts_:.sp.nf$ \fBpg_dump -T 'ts_*' mydb > db.sql\fR.sp.fi.PPTo specify an upper-case or mixed-case name in \fB-t\fR and relatedswitches, you need to double-quote the name; else it will be folded tolower case (see Patterns [\fBpsql\fR(1)]). Butdouble quotes are special to the shell, so in turn they must be quoted.Thus, to dump a single table with a mixed-case name, you need somethinglike.sp.nf$ \fBpg_dump -t '"MixedCaseName"' mydb > mytab.sql\fR.sp.fi.SH "HISTORY".PPThe \fBpg_dump\fR utility first appeared in\fBPostgres95\fR release 0.02. Thenon-plain-text output formats were introduced inPostgreSQL release 7.1..SH "SEE ALSO"\fBpg_dumpall\fR(1), \fBpg_restore\fR(1), \fBpsql\fR(1)

⌨️ 快捷键说明

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