1
1
<!--
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 $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -536,7 +536,7 @@ Type: \copyright for distribution terms
536
536
\g or terminate with semicolon to execute query
537
537
\q to quit
538
538
539
- testdb=>
539
+ testdb=>
540
540
</programlisting>
541
541
</para>
542
542
@@ -881,7 +881,7 @@ testdb=>
881
881
types, relations (tables, views, indexes, sequences, large
882
882
objects), rules, and triggers.) For example:
883
883
<programlisting>
884
- => <userinput>\dd version</userinput>
884
+ => <userinput>\dd version</userinput>
885
885
Object descriptions
886
886
Schema | Name | Object | Description
887
887
------------+---------+----------+---------------------------
@@ -1107,7 +1107,7 @@ testdb=>
1107
1107
space and followed by a newline. This can be useful to
1108
1108
intersperse information in the output of scripts. For example:
1109
1109
<programlisting>
1110
- => <userinput>\echo `date`</userinput>
1110
+ => <userinput>\echo `date`</userinput>
1111
1111
Tue Oct 26 21:40:57 CEST 1999
1112
1112
</programlisting>
1113
1113
If the first argument is an unquoted <literal>-n</literal> the trailing
@@ -1271,7 +1271,7 @@ Tue Oct 26 21:40:57 CEST 1999
1271
1271
large object. Optionally, it associates the given
1272
1272
comment with the object. Example:
1273
1273
<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>
1275
1275
lo_import 152801
1276
1276
</programlisting>
1277
1277
The response indicates that the large object received object ID
@@ -1817,14 +1817,14 @@ lo_import 152801
1817
1817
<application>psql</application> meta-command
1818
1818
<command>\set</command>:
1819
1819
<programlisting>
1820
- testdb=> <userinput>\set foo bar</userinput>
1820
+ testdb=> <userinput>\set foo bar</userinput>
1821
1821
</programlisting>
1822
1822
sets the variable <literal>foo</literal> to the value
1823
1823
<literal>bar</literal>. To retrieve the content of the variable, precede
1824
1824
the name with a colon and use it as the argument of any slash
1825
1825
command:
1826
1826
<programlisting>
1827
- testdb=> <userinput>\echo :foo</userinput>
1827
+ testdb=> <userinput>\echo :foo</userinput>
1828
1828
bar
1829
1829
</programlisting>
1830
1830
</para>
@@ -2154,8 +2154,8 @@ bar
2154
2154
this is again to prepend the variable name with a colon
2155
2155
(<literal>:</literal>).
2156
2156
<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>
2159
2159
</programlisting>
2160
2160
would then query the table <literal>my_table</literal>. The value of
2161
2161
the variable is copied literally, so it can even contain unbalanced
@@ -2171,15 +2171,15 @@ testdb=> <userinput>SELECT * FROM :foo;</userinput>
2171
2171
copy the contents of a file into a table column. First load the file into a
2172
2172
variable and then proceed as above.
2173
2173
<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>
2176
2176
</programlisting>
2177
2177
One possible problem with this approach is that <filename>my_file.txt</filename>
2178
2178
might contain single quotes. These need to be escaped so that
2179
2179
they don't cause a syntax error when the second line is processed. This
2180
2180
could be done with the program <command>sed</command>:
2181
2181
<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>
2183
2183
</programlisting>
2184
2184
Observe the correct number of backslashes (6)! It works
2185
2185
this way: After <application>psql</application> has parsed this
@@ -2384,7 +2384,7 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
2384
2384
<literal>%]</literal>. Multiple pairs of these may occur within
2385
2385
the prompt. For example,
2386
2386
<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%#%] '
2388
2388
</programlisting>
2389
2389
results in a boldfaced (<literal>1;</literal>) yellow-on-black
2390
2390
(<literal>33;40</literal>) prompt on VT100-compatible, color-capable
@@ -2569,7 +2569,7 @@ $endif
2569
2569
discouraged. If you get strange messages, keep this in mind.
2570
2570
For example
2571
2571
<programlisting>
2572
- testdb=> <userinput>\foo</userinput>
2572
+ testdb=> <userinput>\foo</userinput>
2573
2573
Field separator is "oo".
2574
2574
</programlisting>
2575
2575
which is perhaps not what one would expect.
@@ -2631,15 +2631,15 @@ Field separator is "oo".
2631
2631
The first example shows how to spread a command over several lines of
2632
2632
input. Notice the changing prompt:
2633
2633
<programlisting>
2634
- testdb=> <userinput>CREATE TABLE my_table (</userinput>
2634
+ testdb=> <userinput>CREATE TABLE my_table (</userinput>
2635
2635
testdb(> <userinput> first integer not null default 0,</userinput>
2636
2636
testdb(> <userinput> second text)</userinput>
2637
- testdb-> <userinput>;</userinput>
2637
+ testdb-> <userinput>;</userinput>
2638
2638
CREATE TABLE
2639
2639
</programlisting>
2640
2640
Now look at the table definition again:
2641
2641
<programlisting>
2642
- testdb=> <userinput>\d my_table</userinput>
2642
+ testdb=> <userinput>\d my_table</userinput>
2643
2643
Table "my_table"
2644
2644
Attribute | Type | Modifier
2645
2645
-----------+---------+--------------------
@@ -2649,13 +2649,13 @@ testdb=> <userinput>\d my_table</userinput>
2649
2649
</programlisting>
2650
2650
Now we change the prompt to something more interesting:
2651
2651
<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=>
2654
2654
</programlisting>
2655
2655
Let's assume you have filled the table with data and want to take a
2656
2656
look at it:
2657
2657
<programlisting>
2658
- peter@localhost testdb=> SELECT * FROM my_table;
2658
+ peter@localhost testdb=> SELECT * FROM my_table;
2659
2659
first | second
2660
2660
-------+--------
2661
2661
1 | one
@@ -2668,9 +2668,9 @@ peter@localhost testdb=> SELECT * FROM my_table;
2668
2668
You can display tables in different ways by using the
2669
2669
<command>\pset</command> command:
2670
2670
<programlisting>
2671
- peter@localhost testdb=> <userinput>\pset border 2</userinput>
2671
+ peter@localhost testdb=> <userinput>\pset border 2</userinput>
2672
2672
Border style is 2.
2673
- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2673
+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2674
2674
+-------+--------+
2675
2675
| first | second |
2676
2676
+-------+--------+
@@ -2681,9 +2681,9 @@ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2681
2681
+-------+--------+
2682
2682
(4 rows)
2683
2683
2684
- peter@localhost testdb=> <userinput>\pset border 0</userinput>
2684
+ peter@localhost testdb=> <userinput>\pset border 0</userinput>
2685
2685
Border style is 0.
2686
- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2686
+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2687
2687
first second
2688
2688
----- ------
2689
2689
1 one
@@ -2692,27 +2692,27 @@ first second
2692
2692
4 four
2693
2693
(4 rows)
2694
2694
2695
- peter@localhost testdb=> <userinput>\pset border 1</userinput>
2695
+ peter@localhost testdb=> <userinput>\pset border 1</userinput>
2696
2696
Border style is 1.
2697
- peter@localhost testdb=> <userinput>\pset format unaligned</userinput>
2697
+ peter@localhost testdb=> <userinput>\pset format unaligned</userinput>
2698
2698
Output format is unaligned.
2699
- peter@localhost testdb=> <userinput>\pset fieldsep ","</userinput>
2699
+ peter@localhost testdb=> <userinput>\pset fieldsep ","</userinput>
2700
2700
Field separator is ",".
2701
- peter@localhost testdb=> <userinput>\pset tuples_only</userinput>
2701
+ peter@localhost testdb=> <userinput>\pset tuples_only</userinput>
2702
2702
Showing 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>
2704
2704
one,1
2705
2705
two,2
2706
2706
three,3
2707
2707
four,4
2708
2708
</programlisting>
2709
2709
Alternatively, use the short commands:
2710
2710
<programlisting>
2711
- peter@localhost testdb=> <userinput>\a \t \x</userinput>
2711
+ peter@localhost testdb=> <userinput>\a \t \x</userinput>
2712
2712
Output format is aligned.
2713
2713
Tuples only is off.
2714
2714
Expanded display is on.
2715
- peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2715
+ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
2716
2716
-[ RECORD 1 ]-
2717
2717
first | 1
2718
2718
second | one
0 commit comments