Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9e292e3e
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9e292e3e
编写于
1月 22, 2005
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More fixes for => and ->, use proper ampersand markups.
上级
2d16f7c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
31 deletion
+31
-31
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+31
-31
未找到文件。
doc/src/sgml/ref/psql-ref.sgml
浏览文件 @
9e292e3e
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.13
0 2005/01/14 00:24:23
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.13
1 2005/01/22 22:31:52
momjian Exp $
PostgreSQL documentation
-->
...
...
@@ -536,7 +536,7 @@ Type: \copyright for distribution terms
\g or terminate with semicolon to execute query
\q to quit
testdb=
>
testdb=
>
</programlisting>
</para>
...
...
@@ -881,7 +881,7 @@ testdb=>
types, relations (tables, views, indexes, sequences, large
objects), rules, and triggers.) For example:
<programlisting>
=
>
<userinput>\dd version</userinput>
=
>
<userinput>\dd version</userinput>
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:
<programlisting>
=
>
<userinput>\echo `date`</userinput>
=
>
<userinput>\echo `date`</userinput>
Tue Oct 26 21:40:57 CEST 1999
</programlisting>
If the first argument is an unquoted <literal>-n</literal> 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:
<programlisting>
foo=
>
<userinput>\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'</userinput>
foo=
>
<userinput>\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'</userinput>
lo_import 152801
</programlisting>
The response indicates that the large object received object ID
...
...
@@ -1817,14 +1817,14 @@ lo_import 152801
<application>psql</application> meta-command
<command>\set</command>:
<programlisting>
testdb=
>
<userinput>\set foo bar</userinput>
testdb=
>
<userinput>\set foo bar</userinput>
</programlisting>
sets the variable <literal>foo</literal> to the value
<literal>bar</literal>. To retrieve the content of the variable, precede
the name with a colon and use it as the argument of any slash
command:
<programlisting>
testdb=
>
<userinput>\echo :foo</userinput>
testdb=
>
<userinput>\echo :foo</userinput>
bar
</programlisting>
</para>
...
...
@@ -2154,8 +2154,8 @@ bar
this is again to prepend the variable name with a colon
(<literal>:</literal>).
<programlisting>
testdb=
>
<userinput>\set foo 'my_table'</userinput>
testdb=
>
<userinput>SELECT * FROM :foo;</userinput>
testdb=
>
<userinput>\set foo 'my_table'</userinput>
testdb=
>
<userinput>SELECT * FROM :foo;</userinput>
</programlisting>
would then query the table <literal>my_table</literal>. The value of
the variable is copied literally, so it can even contain unbalanced
...
...
@@ -2171,15 +2171,15 @@ testdb=> <userinput>SELECT * FROM :foo;</userinput>
copy the contents of a file into a table column. First load the file into a
variable and then proceed as above.
<programlisting>
testdb=
>
<userinput>\set content '\'' `cat my_file.txt` '\''</userinput>
testdb=
>
<userinput>INSERT INTO my_table VALUES (:content);</userinput>
testdb=
>
<userinput>\set content '\'' `cat my_file.txt` '\''</userinput>
testdb=
>
<userinput>INSERT INTO my_table VALUES (:content);</userinput>
</programlisting>
One possible problem with this approach is that <filename>my_file.txt</filename>
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 <command>sed</command>:
<programlisting>
testdb=
>
<userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''</userinput>
testdb=
>
<userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\''</userinput>
</programlisting>
Observe the correct number of backslashes (6)! It works
this way: After <application>psql</application> has parsed this
...
...
@@ -2384,7 +2384,7 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
<literal>%]</literal>. Multiple pairs of these may occur within
the prompt. For example,
<programlisting>
testdb=
>
\set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
testdb=
>
\set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
</programlisting>
results in a boldfaced (<literal>1;</literal>) yellow-on-black
(<literal>33;40</literal>) prompt on VT100-compatible, color-capable
...
...
@@ -2569,7 +2569,7 @@ $endif
discouraged. If you get strange messages, keep this in mind.
For example
<programlisting>
testdb=
>
<userinput>\foo</userinput>
testdb=
>
<userinput>\foo</userinput>
Field separator is "oo".
</programlisting>
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:
<programlisting>
testdb=
>
<userinput>CREATE TABLE my_table (</userinput>
testdb=
>
<userinput>CREATE TABLE my_table (</userinput>
testdb(> <userinput> first integer not null default 0,</userinput>
testdb(> <userinput> second text)</userinput>
testdb-
>
<userinput>;</userinput>
testdb-
>
<userinput>;</userinput>
CREATE TABLE
</programlisting>
Now look at the table definition again:
<programlisting>
testdb=
>
<userinput>\d my_table</userinput>
testdb=
>
<userinput>\d my_table</userinput>
Table "my_table"
Attribute | Type | Modifier
-----------+---------+--------------------
...
...
@@ -2649,13 +2649,13 @@ testdb=> <userinput>\d my_table</userinput>
</programlisting>
Now we change the prompt to something more interesting:
<programlisting>
testdb=
>
<userinput>\set PROMPT1 '%n@%m %~%R%# '</userinput>
peter@localhost testdb=
>
testdb=
>
<userinput>\set PROMPT1 '%n@%m %~%R%# '</userinput>
peter@localhost testdb=
>
</programlisting>
Let's assume you have filled the table with data and want to take a
look at it:
<programlisting>
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
<command>\pset</command> command:
<programlisting>
peter@localhost testdb=
>
<userinput>\pset border 2</userinput>
peter@localhost testdb=
>
<userinput>\pset border 2</userinput>
Border style is 2.
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
+-------+--------+
| first | second |
+-------+--------+
...
...
@@ -2681,9 +2681,9 @@ peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
+-------+--------+
(4 rows)
peter@localhost testdb=
>
<userinput>\pset border 0</userinput>
peter@localhost testdb=
>
<userinput>\pset border 0</userinput>
Border style is 0.
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
first second
----- ------
1 one
...
...
@@ -2692,15 +2692,15 @@ first second
4 four
(4 rows)
peter@localhost testdb=
>
<userinput>\pset border 1</userinput>
peter@localhost testdb=
>
<userinput>\pset border 1</userinput>
Border style is 1.
peter@localhost testdb=
>
<userinput>\pset format unaligned</userinput>
peter@localhost testdb=
>
<userinput>\pset format unaligned</userinput>
Output format is unaligned.
peter@localhost testdb=
>
<userinput>\pset fieldsep ","</userinput>
peter@localhost testdb=
>
<userinput>\pset fieldsep ","</userinput>
Field separator is ",".
peter@localhost testdb=
>
<userinput>\pset tuples_only</userinput>
peter@localhost testdb=
>
<userinput>\pset tuples_only</userinput>
Showing only tuples.
peter@localhost testdb=
>
<userinput>SELECT second, first FROM my_table;</userinput>
peter@localhost testdb=
>
<userinput>SELECT second, first FROM my_table;</userinput>
one,1
two,2
three,3
...
...
@@ -2708,11 +2708,11 @@ four,4
</programlisting>
Alternatively, use the short commands:
<programlisting>
peter@localhost testdb=
>
<userinput>\a \t \x</userinput>
peter@localhost testdb=
>
<userinput>\a \t \x</userinput>
Output format is aligned.
Tuples only is off.
Expanded display is on.
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
peter@localhost testdb=
>
<userinput>SELECT * FROM my_table;</userinput>
-[ RECORD 1 ]-
first | 1
second | one
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录