11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.130 2005/01/14 00:24:23 momjian Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.131 2005/01/22 22:31:52 momjian Exp $
33PostgreSQL documentation
44-->
55
@@ -536,7 +536,7 @@ Type: \copyright for distribution terms
536536 \g or terminate with semicolon to execute query
537537 \q to quit
538538
539- testdb=>
539+ testdb=>
540540</programlisting>
541541 </para>
542542
@@ -881,7 +881,7 @@ testdb=>
881881 types, relations (tables, views, indexes, sequences, large
882882 objects), rules, and triggers.) For example:
883883<programlisting>
884- => <userinput>\dd version</userinput>
884+ => <userinput>\dd version</userinput>
885885 Object descriptions
886886 Schema | Name | Object | Description
887887------------+---------+----------+---------------------------
@@ -1107,7 +1107,7 @@ testdb=>
11071107 space and followed by a newline. This can be useful to
11081108 intersperse information in the output of scripts. For example:
11091109<programlisting>
1110- => <userinput>\echo `date`</userinput>
1110+ => <userinput>\echo `date`</userinput>
11111111Tue Oct 26 21:40:57 CEST 1999
11121112</programlisting>
11131113 If the first argument is an unquoted <literal>-n</literal> the trailing
@@ -1271,7 +1271,7 @@ Tue Oct 26 21:40:57 CEST 1999
12711271 large object. Optionally, it associates the given
12721272 comment with the object. Example:
12731273<programlisting>
1274- foo=> <userinput>\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'</userinput>
1274+ foo=> <userinput>\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'</userinput>
12751275lo_import 152801
12761276</programlisting>
12771277 The response indicates that the large object received object ID
@@ -1817,14 +1817,14 @@ lo_import 152801
18171817 <application>psql</application> meta-command
18181818 <command>\set</command>:
18191819<programlisting>
1820- testdb=> <userinput>\set foo bar</userinput>
1820+ testdb=> <userinput>\set foo bar</userinput>
18211821</programlisting>
18221822 sets the variable <literal>foo</literal> to the value
18231823 <literal>bar</literal>. To retrieve the content of the variable, precede
18241824 the name with a colon and use it as the argument of any slash
18251825 command:
18261826<programlisting>
1827- testdb=> <userinput>\echo :foo</userinput>
1827+ testdb=> <userinput>\echo :foo</userinput>
18281828bar
18291829</programlisting>
18301830 </para>
@@ -2154,8 +2154,8 @@ bar
21542154 this is again to prepend the variable name with a colon
21552155 (<literal>:</literal>).
21562156<programlisting>
2157- testdb=> <userinput>\set foo 'my_table'</userinput>
2158- testdb=> <userinput>SELECT * FROM :foo;</userinput>
2157+ testdb=> <userinput>\set foo 'my_table'</userinput>
2158+ testdb=> <userinput>SELECT * FROM :foo;</userinput>
21592159</programlisting>
21602160 would then query the table <literal>my_table</literal>. The value of
21612161 the variable is copied literally, so it can even contain unbalanced
@@ -2171,15 +2171,15 @@ testdb=> <userinput>SELECT * FROM :foo;</userinput>
21712171 copy the contents of a file into a table column. First load the file into a
21722172 variable and then proceed as above.
21732173<programlisting>
2174- testdb=> <userinput>\set content '\'' `cat my_file.txt` '\''</userinput>
2175- testdb=> <userinput>INSERT INTO my_table VALUES (:content);</userinput>
2174+ testdb=> <userinput>\set content '\'' `cat my_file.txt` '\''</userinput>
2175+ testdb=> <userinput>INSERT INTO my_table VALUES (:content);</userinput>
21762176</programlisting>
21772177 One possible problem with this approach is that <filename>my_file.txt</filename>
21782178 might contain single quotes. These need to be escaped so that
21792179 they don't cause a syntax error when the second line is processed. This
21802180 could be done with the program <command>sed</command>:
21812181<programlisting>
2182- testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''</userinput>
2182+ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''</userinput>
21832183</programlisting>
21842184 Observe the correct number of backslashes (6)! It works
21852185 this way: After <application>psql</application> has parsed this
@@ -2384,7 +2384,7 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
23842384 <literal>%]</literal>. Multiple pairs of these may occur within
23852385 the prompt. For example,
23862386<programlisting>
2387- testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
2387+ testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
23882388</programlisting>
23892389 results in a boldfaced (<literal>1;</literal>) yellow-on-black
23902390 (<literal>33;40</literal>) prompt on VT100-compatible, color-capable
@@ -2569,7 +2569,7 @@ $endif
25692569 discouraged. If you get strange messages, keep this in mind.
25702570 For example
25712571<programlisting>
2572- testdb=> <userinput>\foo</userinput>
2572+ testdb=> <userinput>\foo</userinput>
25732573Field separator is "oo".
25742574</programlisting>
25752575 which is perhaps not what one would expect.
@@ -2631,15 +2631,15 @@ Field separator is "oo".
26312631 The first example shows how to spread a command over several lines of
26322632 input. Notice the changing prompt:
26332633<programlisting>
2634- testdb=> <userinput>CREATE TABLE my_table (</userinput>
2634+ testdb=> <userinput>CREATE TABLE my_table (</userinput>
26352635testdb(> <userinput> first integer not null default 0,</userinput>
26362636testdb(> <userinput> second text)</userinput>
2637- testdb-> <userinput>;</userinput>
2637+ testdb-> <userinput>;</userinput>
26382638CREATE TABLE
26392639</programlisting>
26402640 Now look at the table definition again:
26412641<programlisting>
2642- testdb=> <userinput>\d my_table</userinput>
2642+ testdb=> <userinput>\d my_table</userinput>
26432643 Table "my_table"
26442644 Attribute | Type | Modifier
26452645-----------+---------+--------------------
@@ -2649,13 +2649,13 @@ testdb=> <userinput>\d my_table</userinput>
26492649</programlisting>
26502650 Now we change the prompt to something more interesting:
26512651<programlisting>
2652- testdb=> <userinput>\set PROMPT1 '%n@%m %~%R%# '</userinput>
2653- peter@localhost testdb=>
2652+ testdb=> <userinput>\set PROMPT1 '%n@%m %~%R%# '</userinput>
2653+ peter@localhost testdb=>
26542654</programlisting>
26552655 Let's assume you have filled the table with data and want to take a
26562656 look at it:
26572657<programlisting>
2658- peter@localhost testdb=> SELECT * FROM my_table;
2658+ peter@localhost testdb=> SELECT * FROM my_table;
26592659 first | second
26602660-------+--------
26612661 1 | one
@@ -2668,9 +2668,9 @@ peter@localhost testdb=> SELECT * FROM my_table;
26682668 You can display tables in different ways by using the
26692669 <command>\pset</command> command:
26702670<programlisting>
2671- peter@localhost testdb=> <userinput>\pset border 2</userinput>
2671+ peter@localhost testdb=> <userinput>\pset border 2</userinput>
26722672Border style is 2.
2673- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2673+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
26742674+-------+--------+
26752675| first | second |
26762676+-------+--------+
@@ -2681,9 +2681,9 @@ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
26812681+-------+--------+
26822682(4 rows)
26832683
2684- peter@localhost testdb=> <userinput>\pset border 0</userinput>
2684+ peter@localhost testdb=> <userinput>\pset border 0</userinput>
26852685Border style is 0.
2686- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2686+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
26872687first second
26882688----- ------
26892689 1 one
@@ -2692,27 +2692,27 @@ first second
26922692 4 four
26932693(4 rows)
26942694
2695- peter@localhost testdb=> <userinput>\pset border 1</userinput>
2695+ peter@localhost testdb=> <userinput>\pset border 1</userinput>
26962696Border style is 1.
2697- peter@localhost testdb=> <userinput>\pset format unaligned</userinput>
2697+ peter@localhost testdb=> <userinput>\pset format unaligned</userinput>
26982698Output format is unaligned.
2699- peter@localhost testdb=> <userinput>\pset fieldsep ","</userinput>
2699+ peter@localhost testdb=> <userinput>\pset fieldsep ","</userinput>
27002700Field separator is ",".
2701- peter@localhost testdb=> <userinput>\pset tuples_only</userinput>
2701+ peter@localhost testdb=> <userinput>\pset tuples_only</userinput>
27022702Showing only tuples.
2703- peter@localhost testdb=> <userinput>SELECT second, first FROM my_table;</userinput>
2703+ peter@localhost testdb=> <userinput>SELECT second, first FROM my_table;</userinput>
27042704one,1
27052705two,2
27062706three,3
27072707four,4
27082708</programlisting>
27092709 Alternatively, use the short commands:
27102710<programlisting>
2711- peter@localhost testdb=> <userinput>\a \t \x</userinput>
2711+ peter@localhost testdb=> <userinput>\a \t \x</userinput>
27122712Output format is aligned.
27132713Tuples only is off.
27142714Expanded display is on.
2715- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2715+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
27162716-[ RECORD 1 ]-
27172717first | 1
27182718second | one