1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
|
<refentry id="APP-PSQL">
<refmeta>
<refentrytitle id="psql-ref">
<application>psql</application>
</refentrytitle>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
<application>psql</application>
</refname>
<refpurpose>
<productname>Postgres</productname> interactive client
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1998-09-26</date>
</refsynopsisdivinfo>
<synopsis>
psql [ <replaceable class="parameter">dbname</replaceable> ]
psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replaceable class="parameter">dbname</replaceable> ]
-e -E [ -f <replaceable class="parameter">filename</replaceable> ] [ -F <replaceable class="parameter">separator</replaceable> ]
[ -h <replaceable class="parameter">hostname</replaceable> ] -Hln [ -o <replaceable class="parameter">filename</replaceable> ]
[ -p <replaceable class="parameter">port</replaceable> ] -qsSt [ -T <replaceable class="parameter">table_o</replaceable> ] -ux
[ <replaceable class="parameter">dbname</replaceable> ]
</synopsis>
<refsect2 id="R2-APP-PSQL-1">
<refsect2info>
<date>1998-09-26</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<application>psql</application> accepts many command-line arguments,
a rich set of meta-commands, and the full <acronym>SQL</acronym> language
supported by <productname>Postgres</productname>. The most common
command-line arguments are:
<variablelist>
<varlistentry>
<term><replaceable class="PARAMETER">dbname</replaceable></term>
<listitem>
<para>
The name of an existing database to access.
<replaceable class="parameter">dbname</replaceable>
defaults to the value of the
<envar>USER</envar>
environment variable or, if that's not set, to the Unix account name of the
current user.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-c <replaceable class="parameter">query</replaceable></term>
<listitem>
<para>
A single query to run. <application>psql</application> will exit on completion.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
The full set of command-line arguments and meta-commands are described in a subsequent
section.
</para>
<para>
There are some environment variables which can be used in liu of
command line arguments.
Additionally, the <productname>Postgres</productname> frontend library used by
the <application>psql</application> application
looks for other optional environment variables to configure, for example,
the style of date/time representation and the local time zone. Refer
to the chapter on <filename>libpq</filename> in the
<citetitle>Programmer's Guide</citetitle> for more details.
</para>
<para>
You may set any of the following environment variables to avoid
specifying command-line options:
<variablelist>
<varlistentry>
<term><envar>PGHOST</envar></term>
<listitem>
<para>
The <acronym>DNS</acronym> host name of the database server.
Setting <envar>PGHOST</envar> to a non-zero-length string causes
<acronym>TCP/IP</acronym> communication
to be used, rather than the default local Unix domain sockets.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>PGPORT</envar></term>
<listitem>
<para>
The port number on which a <productname>Postgres</productname> server is listening.
Defaults to <literal>5432</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>PGTTY</envar></term>
<listitem>
<para>
The target for display of messages from the client support library.
Not required.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>PGOPTION</envar></term>
<listitem>
<para>
If <envar>PGOPTION</envar>
is specified, then the options it contains are parsed
<emphasis>before</emphasis>
any command-line options.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>PGREALM</envar></term>
<listitem>
<para>
<envar>PGREALM</envar>
only applies if
<productname>Kerberos</productname>
authentication is in use.
If this environment variable is set, <productname>Postgres</productname>
will attempt authentication with servers for this realm and will use
separate ticket files to avoid conflicts with local ticket files.
See the <citetitle>PostgreSQL Administrator's Guide</citetitle>
for additional information on
<productname>Kerberos</productname>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-APP-PSQL-2">
<refsect2info>
<date>1998-09-26</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<application>psql</application>
returns 0 to the shell on successful completion of all queries,
1 for errors, 2 for abrupt disconnection from the backend.
<application>psql</application>
will also return 1 if the connection to a database could not be made for
any reason.
</para>
<para>
The default TAB delimiter is used.
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-PSQL-1">
<refsect1info>
<date>1998-09-26</date>
</refsect1info>
<title>
Description
</title>
<para>
<application>psql</application> is a character-based front-end to
<productname>Postgres</productname>.
It enables you to
type in queries interactively, issue them to <productname>Postgres</productname>,
and see the query
results.
</para>
<para>
<application>psql</application>
is a <productname>Postgres</productname> client application. Hence, a
<application>postmaster</application> process
must be running on the database server host before
<application>psql</application>
is executed. In addition, the correct parameters to identify
the database server, such as the
<application>postmaster</application> host name,
may need to be specified
as described below.
</para>
<para>
When
<application>psql</application>
starts, it reads SQL commands from
<filename>/etc/psqlrc</filename>
and then from
<filename>$(<envar>HOME</envar>)/.psqlrc</filename>
This allows SQL commands like
<command>SET</command>
which can be used to set the date style to be run at the start of
every session.
</para>
<refsect2 id="R2-APP-PSQL-3">
<refsect2info>
<date>1998-09-26</date>
</refsect2info>
<title>
Connecting To A Database
</title>
<para>
<application>psql</application>
attempts to make a connection to the database at the hostname and
port number specified on the command line. If the connection could not
be made for any reason (e.g. insufficient privileges, postmaster is not
running on the server, etc)
.IR <application>psql</application>
will return an error that says
<programlisting>
Connection to database failed.
</programlisting>
The reason for the connection failure is not provided.
</para>
</refsect2>
<refsect2 id="R2-APP-PSQL-4">
<refsect2info>
<date>1998-09-26</date>
</refsect2info>
<title>
Entering Queries
</title>
<para>
In normal operation,
<application>psql</application> provides a prompt with the name of the
database that <application>psql</application> is current connected to
followed by the string "=>".
For example,
<programlisting>
$ <userinput>psql testdb</userinput>
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
[PostgreSQL 6.5.0 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3]
type \? for help on slash commands
type \q to quit
type \g or terminate with semicolon to execute query
You are currently connected to the database: testdb
testdb=>
</programlisting>
</para>
<para>
At the prompt, the user may type in <acronym>SQL</acronym> queries.
Unless the -S option
is set, input lines are sent to the backend when a query-terminating
semicolon is reached.
</para>
<para>
Whenever a query is executed,
<application>psql</application> also polls for asynchronous notification
events generated by <command>LISTEN</command> and <command>NOTIFY</command>.
</para>
<para>
<application>psql</application>
can be used in a pipe sequence, and automatically detects when it
is not listening or talking to a real tty.
</para>
</refsect2>
<refsect2 id="R2-APP-PSQL-5">
<title>Paging To Screen</title>
<note>
<title>Author</title>
<para>
From Brett McCormick on the mailing list 1998-04-04.
</para>
</note>
<para>
To affect the paging behavior of your <command>psql</command> output,
set or unset your PAGER environment variable. I always have to set mine
before it will pause. And of course you have to do this before
starting the program.
</para>
<para>
In csh/tcsh or other C shells:
<programlisting>
% unsetenv PAGER
</programlisting>
while in sh/bash or other Bourne shells:
<programlisting>
% unset PAGER
</programlisting>
</para>
</refsect2>
</refsect1>
<refsect1 id="R1-APP-PSQL-2">
<refsect1info>
<date>1998-09-26</date>
</refsect1info>
<title>
Command-line Options
</title>
<para>
<application>psql</application>
understands the following command-line options:
<variablelist>
<varlistentry>
<term>-A</term>
<listitem>
<para>
Turn off fill justification when printing out table elements.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-c <replaceable class="parameter">query</replaceable></term>
<listitem>
<para>
Specifies that
<application>psql</application>
is to execute one query string,
<replaceable class="parameter">query</replaceable>,
and then exit. This is useful for shell scripts, typically in
conjunction with the <option>-q</option> option in shell scripts.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-d <replaceable class="parameter">dbname</replaceable></term>
<listitem>
<para>
Specifies the name of the database to connect to. This is equivalent to specifying
<replaceable class="parameter">dbname</replaceable> as the last field in the
command line.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-e</term>
<listitem>
<para>
Echo the query sent to the backend
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-E</term>
<listitem>
<para>
Echo the actual query generated by \d and other backslash commands
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-f <replaceable class="parameter">filename</replaceable></term>
<listitem>
<para>
Use the file <replaceable class="parameter">filename</replaceable>
as the source of queries instead of reading queries interactively.
This file must be specified for and visible to the client frontend.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-F <replaceable class="parameter">separator</replaceable></term>
<listitem>
<para>
Use <replaceable class="parameter">separator</replaceable>
as the field separator.
The default is an ASCII vertical bar ("|").
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-h <replaceable class="parameter">hostname</replaceable></term>
<listitem>
<para>
Specifies the host name of the machine on which the
<application>postmaster</application>
is running.
Without this option, communication is performed using
local Unix domain sockets.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-H</term>
<listitem>
<para>
Turns on
<acronym>HTML 3.0</acronym>
tabular output.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-l</term>
<listitem>
<para>
Lists all available databases, then exit. Other non-connection options are ignored.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-n</term>
<listitem>
<para>
Do not use the readline library for input line editing and command history.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-o <replaceable class="parameter">filename</replaceable></term>
<listitem>
<para>
Put all output into file <replaceable class="parameter">filename</replaceable>.
The path must be writable by the client.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-p <replaceable class="parameter">port</replaceable></term>
<listitem>
<para>
Specifies the TCP/IP port or, by omission, the local Unix domain socket file
extension on which the
<application>postmaster</application>
is listening for connections. Defaults to the value of the
<envar>PGPORT</envar>
environment variable, if set, or to 5432.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-q</term>
<listitem>
<para>
Specifies that
<application>psql</application>
should do its work quietly. By default, it
prints welcome and exit messages and prompts for each query, and prints
out the number of rows returned from a query.
If this option is used, none of this happens. This is useful with the
<option>-c</option> option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-s</term>
<listitem>
<para>
Run in single-step mode where the user is prompted for each query before
it is sent to the backend.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-S</term>
<listitem>
<para>
Runs in single-line mode where each query is terminated by a newline,
instead of a semicolon.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-t</term>
<listitem>
<para>
Turn off printing of column names.
This is useful with the
<option>-c</option>
option in shell scripts.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-T <replaceable class="parameter">table_options</replaceable></term>
<listitem>
<para>
Allows you to specify options to be placed within the
<sgmltag>table ...</sgmltag> tag for <acronym>HTML 3.0</acronym>
tabular output.For example, <literal>border</literal>
will give you tables with borders.
This must be used in conjunction with the <option>-H</option> option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-u</term>
<listitem>
<para>
Asks the user for the user name and password before connecting to the database.
If the database does not require password authentication then these are
ignored. If the option is not used (and the PGPASSWORD environment variable
is not set) and the database requires password authentication, then the
connection will fail. The user name is ignored anyway.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-x</term>
<listitem>
<para>
Turns on extended row format mode. When enabled each row will have its column
names printed on the left with the column values printed on the right.
This is useful for rows which are otherwise too long to fit into
one screen line. HTML row output supports this mode also.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
You may set environment variables to avoid typing some of the above
options. See the section on environment variables below.
</para>
</refsect1>
<refsect1 id="R1-APP-PSQL-3">
<refsect1info>
<date>1998-09-26</date>
</refsect1info>
<title>
<application>psql</application> Meta-Commands
</title>
<para>
Anything you enter in <application>psql</application>
that begins with an unquoted backslash is a <application>psql</application>
meta-command. Anything else is <acronym>SQL</acronym>
and simply goes into the current query buffer
(and once you have at least one complete query, it gets automatically
submitted to the backend).
<application>psql</application> meta-commands are also called slash commands.
</para>
<para>
The format of a <application>psql</application> command is the backslash,
followed immediately by
a command verb, then any arguments. The arguments are separated from the
command verb and each other by any number of white space characters.
</para>
<para>
With single character command verbs, you don't actually need to separate the
command verb from the argument with white space, for historical reasons.
You should anyway.
</para>
<para>
The following meta-commands are defined:
<variablelist>
<varlistentry>
<term><literal>\a</literal></term>
<listitem>
<para>
Toggle field alignment when printing out table elements.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\C</literal> <replaceable class="parameter">caption</replaceable></term>
<listitem>
<para>
Set the HTML3.0 table caption to
<quote><replaceable class="parameter">caption</replaceable></quote>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\connect</literal> <replaceable class="parameter">meter"</replaceable>ceable> [ <replaceable class="parameter">username</replaceable> ]</term>
<listitem>
<para>
Establish a connection to a new database, using the default
<replaceable class="parameter">username</replaceable> if none is specified.
The previous connection is closed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\copy</literal> <replaceable class="parameter">meter"</replaceable>ceable> { FROM | TO } <replaceable class="parameter">filename</replaceable>
</term>
<listitem>
<para>
Perform a frontend (client) copy. This is an operation that runs a SQL COPY command,
but instead of the backend reading or writing the specified file, and
consequently requiring backend access and special user privilege,
<application>psql</application> reads or writes the
file and routes the data to or from the backend. The default
<literal>tab</literal>
delimiter is used.
</para>
<tip>
<para>
This operation is not as efficient as the <acronym>SQL</acronym>
<command>COPY</command> command because all data must pass through the
client/server IP or socket connection. For large amounts of data this other
technique may be preferable.
</para>
</tip>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\d</literal> [ <replaceable class="parameter">table</replaceable> ]</term>
<listitem>
<para>
List tables in the database, or if <replaceable
class="parameter">table</replaceable>
is specified, list the columns in that table.
If table name is specified as an asterisk (<quote>*</quote>),
list all tables and column information for each tables.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\da</literal></term>
<listitem>
<para>
List all available aggregates.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\dd</literal> <replaceable class="parameter">object</replaceable></term>
<listitem>
<para>
List the description from <literal>pg_description</literal>
of the specified object, which can be a
table, table.column, type, operator, or aggregate.
</para>
<tip>
<para>
Not all objects have a description in <literal>pg_description</literal>.
This meta-command can be useful to get a quick description of a native
<productname>Postgres</productname> feature.
</para>
</tip>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\df</literal></term>
<listitem>
<para>
List functions.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\di</literal></term>
<listitem>
<para>
List only indexes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\do</literal></term>
<listitem>
<para>
List only operators.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\ds</literal></term>
<listitem>
<para>
List only sequences.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\dS</literal></term>
<listitem>
<para>
List system tables and indexes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\dt</literal></term>
<listitem>
<para>
List only non-system tables.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\dT</literal></term>
<listitem>
<para>
List types.
</para>
</listitem>
</varlistentry>
<varlistentry><term>
<literal>\e</literal> [ <replaceable class="parameter">filename</replaceable> ]</term>
<listitem>
<para>
Edit the current query buffer or the contents of the file
<replaceable class="parameter">filename</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\E</literal> [ <replaceable class="parameter">filename</replaceable> ]</term>
<listitem>
<para>
Edit the current query buffer or the contents of the file
<replaceable class="parameter">filename</replaceable>
and execute it upon editor exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\f</literal> [ <replaceable class="parameter">separator</replaceable> ]</term>
<listitem>
<para>
Set the field separator. Default is a single blank space.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]</term>
<listitem>
<para>
Send the current query input buffer to the backend and optionally
save the output in <replaceable class="parameter">filename</replaceable>
or pipe the output into a separate Unix shell to execute
<replaceable class="parameter">command</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\h</literal> [ <replaceable class="parameter">command</replaceable> ]</term>
<listitem>
<para>
Give syntax help on the specified SQL command.
If <replaceable class="parameter">command</replaceable> is not a defined SQL command
(or is not documented in <application>psql</application>), or if
<replaceable class="parameter">command</replaceable> is not specified,
then <application>psql</application> will
list all the commands for which syntax help is
available. If <replaceable class="parameter">command</replaceable>
is an asterisk (<quote>*</quote>), then
give syntax help on all SQL commands.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\H</literal></term>
<listitem>
<para>
Toggle <acronym>HTML3</acronym> output. This is equivalent to
the <option>-H</option>
command-line option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\i</literal> <replaceable class="parameter">filename</replaceable></term>
<listitem>
<para>
Read queries from the file <replaceable class="parameter">filename</replaceable>
into the query input buffer.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\l</literal></term>
<listitem>
<para>
List all the databases in the server.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\m</literal></term>
<listitem>
<para>
Toggle the old monitor-like table display, which includes border characters
surrounding the table.
This is standard SQL output.
By default, <application>psql</application> includes only field separators
between columns.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\o</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]</term>
<listitem>
<para>
Save future query results to the file
<replaceable class="parameter">filename</replaceable> or pipe future
results into a separate Unix shell to execute
<replaceable class="parameter">command</replaceable>.
If no arguments are specified, send query results to
<filename>stdout</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\p</literal></term>
<listitem>
<para>
Print the current query buffer.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\q</literal></term>
<listitem>
<para>
Quit the <application>psql</application> program.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\r</literal></term>
<listitem>
<para>
Reset(clear) the query buffer.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\s</literal> [ <replaceable class="parameter">filename</replaceable> ]</term>
<listitem>
<para>
Print or save the command line history to
<replaceable class="parameter">filename</replaceable>.
If <replaceable class="parameter">filename</replaceable> is omitted,
do not save subsequent commands to a history file.
This option is only available if <application>psql</application> is
configured to use readline.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\t</literal></term>
<listitem>
<para>
Toggle display of output column name headings and row count footer (defaults to on).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\T</literal> <replaceable class="parameter">table_options</replaceable></term>
<listitem>
<para>
Allows you to specify options to be placed within the
<sgmltag>table ...</sgmltag> tag
for <acronym>HTML 3.0</acronym>
tabular output.For example, <literal>border</literal>
will give you tables with borders.
This must be used in conjunction with the <command>\H</command> meta-command.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\x</literal></term>
<listitem>
<para>
Toggles extended row format mode. When enabled each row will have its column
names printed on the left with the column values printed on the right.
This is useful for rows which are otherwise too long to fit into
one screen line. <acronym>HTML</acronym> row output mode supports this flag too.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\w</literal> <replaceable class="parameter">filename</replaceable></term>
<listitem>
<para>
Outputs the current query buffer to the file
<replaceable class="parameter">filename</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\z</literal></term>
<listitem>
<para>
Produces a list of all tables in the database with their appropriate ACLs
(grant/revoke permissions) listed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\!</literal> [ <replaceable class="parameter">command</replaceable> ]</term>
<listitem>
<para>
Escape to a separate Unix shell or execute the Unix command
<replaceable class="parameter">command</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>\?</literal></term>
<listitem>
<para>
Get help information about the slash (<quote>\</quote>) commands.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
|