diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index b5bf703a71..e69248d716 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1,5 +1,5 @@ @@ -536,7 +536,7 @@ Type: \copyright for distribution terms \g or terminate with semicolon to execute query \q to quit -testdb=> +testdb=> @@ -881,7 +881,7 @@ testdb=> types, relations (tables, views, indexes, sequences, large objects), rules, and triggers.) For example: -=> \dd version +=> \dd version Object descriptions Schema | Name | Object | Description ------------+---------+----------+--------------------------- @@ -1107,7 +1107,7 @@ testdb=> space and followed by a newline. This can be useful to intersperse information in the output of scripts. For example: -=> \echo `date` +=> \echo `date` Tue Oct 26 21:40:57 CEST 1999 If the first argument is an unquoted -n the trailing @@ -1271,7 +1271,7 @@ Tue Oct 26 21:40:57 CEST 1999 large object. Optionally, it associates the given comment with the object. Example: -foo=> \lo_import '/home/peter/pictures/photo.xcf' 'a picture of me' +foo=> \lo_import '/home/peter/pictures/photo.xcf' 'a picture of me' lo_import 152801 The response indicates that the large object received object ID @@ -1817,14 +1817,14 @@ lo_import 152801 psql meta-command \set: -testdb=> \set foo bar +testdb=> \set foo bar sets the variable foo to the value bar. To retrieve the content of the variable, precede the name with a colon and use it as the argument of any slash command: -testdb=> \echo :foo +testdb=> \echo :foo bar @@ -2154,8 +2154,8 @@ bar this is again to prepend the variable name with a colon (:). -testdb=> \set foo 'my_table' -testdb=> SELECT * FROM :foo; +testdb=> \set foo 'my_table' +testdb=> SELECT * FROM :foo; would then query the table my_table. The value of the variable is copied literally, so it can even contain unbalanced @@ -2171,15 +2171,15 @@ testdb=> SELECT * FROM :foo; copy the contents of a file into a table column. First load the file into a variable and then proceed as above. -testdb=> \set content '\'' `cat my_file.txt` '\'' -testdb=> INSERT INTO my_table VALUES (:content); +testdb=> \set content '\'' `cat my_file.txt` '\'' +testdb=> INSERT INTO my_table VALUES (:content); One possible problem with this approach is that my_file.txt might contain single quotes. These need to be escaped so that they don't cause a syntax error when the second line is processed. This could be done with the program sed: -testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'' +testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'' Observe the correct number of backslashes (6)! It works this way: After psql has parsed this @@ -2384,7 +2384,7 @@ testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\' %]. Multiple pairs of these may occur within the prompt. For example, -testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] ' +testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] ' results in a boldfaced (1;) yellow-on-black (33;40) prompt on VT100-compatible, color-capable @@ -2569,7 +2569,7 @@ $endif discouraged. If you get strange messages, keep this in mind. For example -testdb=> \foo +testdb=> \foo Field separator is "oo". which is perhaps not what one would expect. @@ -2631,15 +2631,15 @@ Field separator is "oo". The first example shows how to spread a command over several lines of input. Notice the changing prompt: -testdb=> CREATE TABLE my_table ( +testdb=> CREATE TABLE my_table ( testdb(> first integer not null default 0, testdb(> second text) -testdb-> ; +testdb-> ; CREATE TABLE Now look at the table definition again: -testdb=> \d my_table +testdb=> \d my_table Table "my_table" Attribute | Type | Modifier -----------+---------+-------------------- @@ -2649,13 +2649,13 @@ testdb=> \d my_table Now we change the prompt to something more interesting: -testdb=> \set PROMPT1 '%n@%m %~%R%# ' -peter@localhost testdb=> +testdb=> \set PROMPT1 '%n@%m %~%R%# ' +peter@localhost testdb=> Let's assume you have filled the table with data and want to take a look at it: -peter@localhost testdb=> SELECT * FROM my_table; +peter@localhost testdb=> SELECT * FROM my_table; first | second -------+-------- 1 | one @@ -2668,9 +2668,9 @@ peter@localhost testdb=> SELECT * FROM my_table; You can display tables in different ways by using the \pset command: -peter@localhost testdb=> \pset border 2 +peter@localhost testdb=> \pset border 2 Border style is 2. -peter@localhost testdb=> SELECT * FROM my_table; +peter@localhost testdb=> SELECT * FROM my_table; +-------+--------+ | first | second | +-------+--------+ @@ -2681,9 +2681,9 @@ peter@localhost testdb=> SELECT * FROM my_table; +-------+--------+ (4 rows) -peter@localhost testdb=> \pset border 0 +peter@localhost testdb=> \pset border 0 Border style is 0. -peter@localhost testdb=> SELECT * FROM my_table; +peter@localhost testdb=> SELECT * FROM my_table; first second ----- ------ 1 one @@ -2692,15 +2692,15 @@ first second 4 four (4 rows) -peter@localhost testdb=> \pset border 1 +peter@localhost testdb=> \pset border 1 Border style is 1. -peter@localhost testdb=> \pset format unaligned +peter@localhost testdb=> \pset format unaligned Output format is unaligned. -peter@localhost testdb=> \pset fieldsep "," +peter@localhost testdb=> \pset fieldsep "," Field separator is ",". -peter@localhost testdb=> \pset tuples_only +peter@localhost testdb=> \pset tuples_only Showing only tuples. -peter@localhost testdb=> SELECT second, first FROM my_table; +peter@localhost testdb=> SELECT second, first FROM my_table; one,1 two,2 three,3 @@ -2708,11 +2708,11 @@ four,4 Alternatively, use the short commands: -peter@localhost testdb=> \a \t \x +peter@localhost testdb=> \a \t \x Output format is aligned. Tuples only is off. Expanded display is on. -peter@localhost testdb=> SELECT * FROM my_table; +peter@localhost testdb=> SELECT * FROM my_table; -[ RECORD 1 ]- first | 1 second | one