Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77d2b1b

Browse files
committed
Improve description of the pattern matching rules used by psql's \d
commands (and soon by pg_dump).
1 parent39ed8c4 commit77d2b1b

File tree

1 file changed

+66
-15
lines changed

1 file changed

+66
-15
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.170 2006/10/03 21:14:46 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.171 2006/10/09 23:31:29 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1817,34 +1817,85 @@ lo_import 152801
18171817
</variablelist>
18181818
</para>
18191819

1820+
<refsect3 id="APP-PSQL-patterns">
1821+
<title id="APP-PSQL-patterns-title">Patterns</title>
1822+
1823+
<indexterm>
1824+
<primary>patterns</primary>
1825+
<secondary>in psql and pg_dump</secondary>
1826+
</indexterm>
1827+
18201828
<para>
18211829
The various <literal>\d</> commands accept a <replaceable
18221830
class="parameter">pattern</replaceable> parameter to specify the
1823-
object name(s) to be displayed. <literal>*</> means <quote>any
1824-
sequence of characters</> and <literal>?</> means <quote>any single
1825-
character</>. (This notation is comparable to Unix shell file name
1826-
patterns.) Advanced users can also use regular-expression
1827-
notations such as character classes, for example <literal>[0-9]</>
1828-
to match <quote>any digit</>. To make any of these
1829-
pattern-matching characters be interpreted literally, surround it
1830-
with double quotes.
1831+
object name(s) to be displayed. In the simplest case, a pattern
1832+
is just the exact name of the object. The characters within a
1833+
pattern are normally folded to lower case, just as in SQL names;
1834+
for example, <literal>\dt FOO</> will display the table named
1835+
<literal>foo</>. As in SQL names, placing double quotes around
1836+
a pattern stops folding to lower case. Should you need to include
1837+
an actual double quote character in a pattern, write it as a pair
1838+
of double quotes within a double-quote sequence; again this is in
1839+
accord with the rules for SQL quoted identifiers. For example,
1840+
<literal>\dt "FOO""BAR"</> will display the table named
1841+
<literal>FOO"BAR</> (not <literal>foo"bar</>). Unlike the normal
1842+
rules for SQL names, you can put double quotes around just part
1843+
of a pattern, for instance <literal>\dt FOO"FOO"BAR</> will display
1844+
the table named <literal>fooFOObar</>.
1845+
</para>
1846+
1847+
<para>
1848+
Within a pattern, <literal>*</> matches any sequence of characters
1849+
(including no characters) and <literal>?</> matches any single character.
1850+
(This notation is comparable to Unix shell file name patterns.)
1851+
For example, <literal>\dt int*</> displays all tables whose names
1852+
begin with <literal>int</>. But within double quotes, <literal>*</>
1853+
and <literal>?</> lose these special meanings and are just matched
1854+
literally.
18311855
</para>
18321856

18331857
<para>
1834-
A pattern that containsan (unquoted) dot is interpreted as a schema
1858+
A pattern that containsa dot (<literal>.</>) is interpreted as a schema
18351859
name pattern followed by an object name pattern. For example,
1836-
<literal>\dt foo*.bar*</> displays all tablesin schemaswhose name
1837-
starts with <literal>foo</>andwhosetable name
1838-
starts with <literal>bar</>.If no dot appears, then the pattern
1860+
<literal>\dt foo*.bar*</> displays all tables whose table name
1861+
starts with <literal>bar</>that are in schemaswhoseschema name
1862+
starts with <literal>foo</>.When no dot appears, then the pattern
18391863
matches only objects that are visible in the current schema search path.
1864+
Again, a dot within double quotes loses its special meaning and is matched
1865+
literally.
1866+
</para>
1867+
1868+
<para>
1869+
Advanced users can use regular-expression notations such as character
1870+
classes, for example <literal>[0-9]</> to match any digit. All regular
1871+
expression special characters work as specified in
1872+
<xref linkend="functions-posix-regexp">, except for <literal>.</> which
1873+
is taken as a separator as mentioned above, <literal>*</> which is
1874+
translated to the regular-expression notation <literal>.*</>, and
1875+
<literal>?</> which is translated to <literal>.</>. You can emulate
1876+
these pattern characters at need by writing
1877+
<literal>?</> for <literal>.</>,
1878+
<literal>(<replaceable class="parameter">R</replaceable>+|)</literal> for
1879+
<literal><replaceable class="parameter">R</replaceable>*</literal>, or
1880+
<literal>(<replaceable class="parameter">R</replaceable>|)</literal> for
1881+
<literal><replaceable class="parameter">R</replaceable>?</literal>.
1882+
Remember that the pattern must match the whole name, unlike the usual
1883+
interpretation of regular expressions; write <literal>*</> at the beginning
1884+
and/or end if you don't wish the pattern to be anchored.
1885+
Note that within double quotes, all regular expression special characters
1886+
lose their special meanings and are matched literally. Also, the regular
1887+
expression special characters are matched literally in operator name
1888+
patterns (i.e., the argument of <literal>\do</>).
18401889
</para>
18411890

18421891
<para>
18431892
Whenever the <replaceable class="parameter">pattern</replaceable> parameter
18441893
is omitted completely, the <literal>\d</> commands display all objects
1845-
that are visible in the current schema search path. To see all objects
1846-
in the database, use the pattern <literal>*.*</>.
1894+
that are visible in the current schema search path &mdash; this is
1895+
equivalent to using the pattern <literal>*</>.
1896+
To see all objects in the database, use the pattern <literal>*.*</>.
18471897
</para>
1898+
</refsect3>
18481899
</refsect2>
18491900

18501901
<refsect2>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp