<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >postgres</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 7.4.1 Documentation" HREF="index.html"><LINK REL="UP" TITLE="PostgreSQL Server Applications" HREF="reference-server.html"><LINK REL="PREVIOUS" TITLE="pg_resetxlog" HREF="app-pgresetxlog.html"><LINK REL="NEXT" TITLE="postmaster" HREF="app-postmaster.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2003-12-22T03:48:47"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" >PostgreSQL 7.4.1 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="app-pgresetxlog.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="app-pgresetxlog.html" >Fast Backward</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="app-postmaster.html" >Fast Forward</A ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="app-postmaster.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="APP-POSTGRES" ></A ><SPAN CLASS="APPLICATION" >postgres</SPAN ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN47798" ></A ><H2 >Name</H2 >postgres -- run a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > server in single-user mode</DIV ><A NAME="AEN47802" ></A ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN47804" ></A ><H2 >Synopsis</H2 ><P ><TT CLASS="COMMAND" >postgres</TT > [-A 0 | 1 ] [-B <VAR CLASS="REPLACEABLE" >nbuffers</VAR >] [-c <VAR CLASS="REPLACEABLE" >name</VAR >=<VAR CLASS="REPLACEABLE" >value</VAR >] [-d <VAR CLASS="REPLACEABLE" >debug-level</VAR >] [--describe-config] [-D <VAR CLASS="REPLACEABLE" >datadir</VAR >] [-e] [-E] [-f s | i | t | n | m | h ] [-F] [-N] [-o <VAR CLASS="REPLACEABLE" >filename</VAR >] [-O] [-P] [-s | -t pa | pl | ex ] [-S <VAR CLASS="REPLACEABLE" >sort-mem</VAR >] [-W <VAR CLASS="REPLACEABLE" >seconds</VAR >] [--<VAR CLASS="REPLACEABLE" >name</VAR >=<VAR CLASS="REPLACEABLE" >value</VAR >] <VAR CLASS="REPLACEABLE" >database</VAR > <BR><TT CLASS="COMMAND" >postgres</TT > [-A 0 | 1 ] [-B <VAR CLASS="REPLACEABLE" >nbuffers</VAR >] [-c <VAR CLASS="REPLACEABLE" >name</VAR >=<VAR CLASS="REPLACEABLE" >value</VAR >] [-d <VAR CLASS="REPLACEABLE" >debug-level</VAR >] [-D <VAR CLASS="REPLACEABLE" >datadir</VAR >] [-e] [-f s | i | t | n | m | h ] [-F] [-o <VAR CLASS="REPLACEABLE" >filename</VAR >] [-O] [-p <VAR CLASS="REPLACEABLE" >database</VAR >] [-P] [-s | -t pa | pl | ex ] [-S <VAR CLASS="REPLACEABLE" >sort-mem</VAR >] [-v <VAR CLASS="REPLACEABLE" >protocol</VAR >] [-W <VAR CLASS="REPLACEABLE" >seconds</VAR >] [--<VAR CLASS="REPLACEABLE" >name</VAR >=<VAR CLASS="REPLACEABLE" >value</VAR >]</P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN47900" ></A ><H2 >Description</H2 ><P > The <TT CLASS="COMMAND" >postgres</TT > executable is the actual <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > server process that processes queries. It is normally not called directly; instead a <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > multiuser server is started. </P ><P > The second form above is how <TT CLASS="COMMAND" >postgres</TT > is invoked by the <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > (only conceptually, since both <TT CLASS="FILENAME" >postmaster</TT > and <TT CLASS="FILENAME" >postgres</TT > are in fact the same program); it should not be invoked directly this way. The first form invokes the server directly in interactive single-user mode. The primary use for this mode is during bootstrapping by <A HREF="app-initdb.html" >initdb</A >. Sometimes it is used for debugging or disaster recovery. </P ><P > When invoked in interactive mode from the shell, the user can enter queries and the results will be printed to the screen, but in a form that is more useful for developers than end users. But note that running a single-user server is not truly suitable for debugging the server since no realistic interprocess communication and locking will happen. </P ><P > When running a stand-alone server, the session user will be set to the user with ID 1. This user does not actually have to exist, so a stand-alone server can be used to manually recover from certain kinds of accidental damage to the system catalogs. Implicit superuser powers are granted to the user with ID 1 in stand-alone mode. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN47914" ></A ><H2 >Options</H2 ><P > When <TT CLASS="COMMAND" >postgres</TT > is started by a <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > then it inherits all options set by the latter. Additionally, <TT CLASS="COMMAND" >postgres</TT >-specific options can be passed from the <TT CLASS="COMMAND" >postmaster</TT > with the <VAR CLASS="OPTION" >-o</VAR > switch. </P ><P > You can avoid having to type these options by setting up a configuration file. See <A HREF="runtime-config.html" >Section 16.4</A > for details. Some (safe) options can also be set from the connecting client in an application-dependent way. For example, if the environment variable <TT CLASS="ENVAR" >PGOPTIONS</TT > is set, then <SPAN CLASS="APPLICATION" >libpq</SPAN >-based clients will pass that string to the server, which will interpret it as <TT CLASS="COMMAND" >postgres</TT > command-line options. </P ><DIV CLASS="REFSECT2" ><A NAME="AEN47927" ></A ><H3 >General Purpose</H3 ><P > The options <VAR CLASS="OPTION" >-A</VAR >, <VAR CLASS="OPTION" >-B</VAR >, <VAR CLASS="OPTION" >-c</VAR >, <VAR CLASS="OPTION" >-d</VAR >, <VAR CLASS="OPTION" >-D</VAR >, <VAR CLASS="OPTION" >-F</VAR >, and <VAR CLASS="OPTION" >--<VAR CLASS="REPLACEABLE" >name</VAR ></VAR > have the same meanings as the <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > except that <TT CLASS="LITERAL" >-d 0</TT > prevents the server log level of the <TT CLASS="COMMAND" >postmaster</TT > from being propagated to <TT CLASS="COMMAND" >postgres</TT >. </P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><VAR CLASS="OPTION" >-e</VAR ></DT ><DD ><P > Sets the default date style to <SPAN CLASS="QUOTE" >"European"</SPAN >, that is <TT CLASS="LITERAL" >DMY</TT > ordering of input date fields. This also causes the day to be printed before the month in certain date output formats. See <A HREF="datatype-datetime.html" >Section 8.5</A > for more information. </P ></DD ><DT ><VAR CLASS="OPTION" >-o</VAR > <VAR CLASS="REPLACEABLE" >filename</VAR ></DT ><DD ><P > Send all server log output to <VAR CLASS="REPLACEABLE" >filename</VAR >. If <TT CLASS="COMMAND" >postgres</TT > is running under the <TT CLASS="COMMAND" >postmaster</TT >, this option is ignored, and the <SPAN CLASS="SYSTEMITEM" >stderr</SPAN > inherited from the <TT CLASS="COMMAND" >postmaster</TT > is used. </P ></DD ><DT ><VAR CLASS="OPTION" >-P</VAR ></DT ><DD ><P > Ignore system indexes when reading system tables (but still update the indexes when modifying the tables). This is useful when recovering from damaged system indexes. </P ></DD ><DT ><VAR CLASS="OPTION" >-s</VAR ></DT ><DD ><P > Print time information and other statistics at the end of each command. This is useful for benchmarking or for use in tuning the number of buffers. </P ></DD ><DT ><VAR CLASS="OPTION" >-S</VAR > <VAR CLASS="REPLACEABLE" >sort-mem</VAR ></DT ><DD ><P > Specifies the amount of memory to be used by internal sorts and hashes before resorting to temporary disk files. The value is specified in kilobytes, and defaults to 1024. Note that for a complex query, several sorts and/or hashes might be running in parallel, and each one will be allowed to use as much as <VAR CLASS="REPLACEABLE" >sort-mem</VAR > kilobytes before it starts to put data into temporary files. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT2" ><A NAME="AEN47979" ></A ><H3 >Options for stand-alone mode</H3 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><VAR CLASS="REPLACEABLE" >database</VAR ></DT ><DD ><P > Specifies the name of the database to be accessed. If it is omitted it defaults to the user name. </P ></DD ><DT ><VAR CLASS="OPTION" >-E</VAR ></DT ><DD ><P > Echo all commands. </P ></DD ><DT ><VAR CLASS="OPTION" >-N</VAR ></DT ><DD ><P > Disables use of newline as a statement delimiter. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT2" ><A NAME="AEN47997" ></A ><H3 >Semi-internal Options</H3 ><P > There are several other options that may be specified, used mainly for debugging purposes. These are listed here only for the use by <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > system developers. <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Use of any of these options is highly discouraged.</I ></SPAN > Furthermore, any of these options may disappear or change in a future release without notice. </P ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><VAR CLASS="OPTION" >-f</VAR > <TT CLASS="LITERAL" >{ s | i | m | n | h }</TT ></DT ><DD ><P > Forbids the use of particular scan and join methods: <TT CLASS="LITERAL" >s</TT > and <TT CLASS="LITERAL" >i</TT > disable sequential and index scans respectively, while <TT CLASS="LITERAL" >n</TT >, <TT CLASS="LITERAL" >m</TT >, and <TT CLASS="LITERAL" >h</TT > disable nested-loop, merge and hash joins respectively. </P ><DIV CLASS="NOTE" ><BLOCKQUOTE CLASS="NOTE" ><P ><B >Note: </B > Neither sequential scans nor nested-loop joins can be disabled completely; the <TT CLASS="LITERAL" >-fs</TT > and <TT CLASS="LITERAL" >-fn</TT > options simply discourage the optimizer from using those plan types if it has any other alternative. </P ></BLOCKQUOTE ></DIV ></DD ><DT ><VAR CLASS="OPTION" >-O</VAR ></DT ><DD ><P > Allows the structure of system tables to be modified. This is used by <TT CLASS="COMMAND" >initdb</TT >. </P ></DD ><DT ><VAR CLASS="OPTION" >-p</VAR > <VAR CLASS="REPLACEABLE" >database</VAR ></DT ><DD ><P > Indicates that this process has been started by a <TT CLASS="COMMAND" >postmaster</TT > and specifies the database to use. etc. </P ></DD ><DT ><VAR CLASS="OPTION" >-t</VAR > <TT CLASS="LITERAL" >pa[rser] | pl[anner] | e[xecutor]</TT ></DT ><DD ><P > Print timing statistics for each query relating to each of the major system modules. This option cannot be used together with the <VAR CLASS="OPTION" >-s</VAR > option. </P ></DD ><DT ><VAR CLASS="OPTION" >-v</VAR > <VAR CLASS="REPLACEABLE" >protocol</VAR ></DT ><DD ><P > Specifies the version number of the frontend/backend protocol to be used for this particular session. </P ></DD ><DT ><VAR CLASS="OPTION" >-W</VAR > <VAR CLASS="REPLACEABLE" >seconds</VAR ></DT ><DD ><P > As soon as this option is encountered, the process sleeps for the specified amount of seconds. This gives developers time to attach a debugger to the server process. </P ></DD ><DT ><VAR CLASS="OPTION" >--describe-config</VAR ></DT ><DD ><P > This option dumps out the server's internal configuration variables, descriptions, and defaults in tab-delimited <TT CLASS="COMMAND" >COPY</TT > format. It is designed primarily for use by administration tools. </P ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN48056" ></A ><H2 >Environment</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="ENVAR" >PGDATA</TT ></DT ><DD ><P > Default data direction location </P ></DD ></DL ></DIV ><P > For others, which have little influence during single-user mode, see <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN48066" ></A ><H2 >Notes</H2 ><P > To cancel a running query, send the <TT CLASS="LITERAL" >SIGINT</TT > signal to the <TT CLASS="COMMAND" >postgres</TT > process running that command. </P ><P > To tell <TT CLASS="COMMAND" >postgres</TT > to reload the configuration files, send a <TT CLASS="LITERAL" >SIGHUP</TT > signal. Normally it's best to <TT CLASS="LITERAL" >SIGHUP</TT > the <TT CLASS="COMMAND" >postmaster</TT > instead; the <TT CLASS="COMMAND" >postmaster</TT > will in turn <TT CLASS="LITERAL" >SIGHUP</TT > each of its children. But in some cases it might be desirable to have only one <TT CLASS="COMMAND" >postgres</TT > process reload the configuration files. </P ><P > The <TT CLASS="COMMAND" >postmaster</TT > uses <TT CLASS="LITERAL" >SIGTERM</TT > to tell a <TT CLASS="COMMAND" >postgres</TT > process to quit normally and <TT CLASS="LITERAL" >SIGQUIT</TT > to terminate without the normal cleanup. These signals <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >should not</I ></SPAN > be used by users. It is also unwise to send <TT CLASS="LITERAL" >SIGKILL</TT > to a <TT CLASS="COMMAND" >postgres</TT > process --- the <TT CLASS="COMMAND" >postmaster</TT > will interpret this as a crash in <TT CLASS="COMMAND" >postgres</TT >, and will force all the sibling <TT CLASS="COMMAND" >postgres</TT > processes to quit as part of its standard crash-recovery procedure. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN48090" ></A ><H2 >Usage</H2 ><P > Start a stand-alone server with a command like </P><PRE CLASS="SCREEN" ><KBD CLASS="USERINPUT" >postgres -D /usr/local/pgsql/data <VAR CLASS="REPLACEABLE" >other-options</VAR > my_database</KBD ></PRE ><P> Provide the correct path to the database directory with <VAR CLASS="OPTION" >-D</VAR >, or make sure that the environment variable <TT CLASS="ENVAR" >PGDATA</TT > is set. Also specify the name of the particular database you want to work in. </P ><P > Normally, the stand-alone server treats newline as the command entry terminator; there is no intelligence about semicolons, as there is in <SPAN CLASS="APPLICATION" >psql</SPAN >. To continue a command across multiple lines, you must type backslash just before each newline except the last one. </P ><P > But if you use the <VAR CLASS="OPTION" >-N</VAR > command line switch, then newline does not terminate command entry. In this case, the server will read the standard input until the end-of-file (<ACRONYM CLASS="ACRONYM" >EOF</ACRONYM >) marker, then process the input as a single command string. Backslash-newline is not treated specially in this case. </P ><P > To quit the session, type <ACRONYM CLASS="ACRONYM" >EOF</ACRONYM > (<B CLASS="KEYCAP" >Control</B >+<B CLASS="KEYCAP" >D</B >, usually). If you've used <VAR CLASS="OPTION" >-N</VAR >, two consecutive <ACRONYM CLASS="ACRONYM" >EOF</ACRONYM >s are needed to exit. </P ><P > Note that the stand-alone server does not provide sophisticated line-editing features (no command history, for example). </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN48111" ></A ><H2 >See Also</H2 ><P > <A HREF="app-initdb.html" >initdb</A >, <A HREF="app-ipcclean.html" ><SPAN CLASS="APPLICATION" >ipcclean</SPAN ></A >, <A HREF="app-postmaster.html" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></A > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="app-pgresetxlog.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="app-postmaster.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><SPAN CLASS="APPLICATION" >pg_resetxlog</SPAN ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="reference-server.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><SPAN CLASS="APPLICATION" >postmaster</SPAN ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >