1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.69 2002/07/28 15:22:21 petere Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.70 2002/08/10 03:56:23 tgl Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -538,7 +538,7 @@ testdb=>
538
538
</para>
539
539
540
540
<para>
541
- To include whitespace into an argument you must quote it with a
541
+ To include whitespace into an argument you may quote it with a
542
542
single quote. To include a single quote into such an argument,
543
543
precede it by a backslash. Anything contained in single quotes is
544
544
furthermore subject to C-like substitutions for
@@ -551,25 +551,24 @@ testdb=>
551
551
552
552
<para>
553
553
If an unquoted argument begins with a colon (<literal>:</literal>),
554
- it is taken as a variable and the value of the variable is taken as
555
- the argument instead.
554
+ it is taken as a <application>psql</> variable and the value of the
555
+ variable is used as the argument instead.
556
556
</para>
557
557
558
558
<para>
559
559
Arguments that are quoted in <quote>backticks</quote>
560
560
(<literal>`</literal>) are taken as a command line that is passed to
561
- the shell. The output of the command (with a trailing newline
561
+ the shell. The output of the command (with any trailing newline
562
562
removed) is taken as the argument value. The above escape sequences
563
563
also apply in backticks.
564
564
</para>
565
565
566
566
<para>
567
- Some commands take the name of an <acronym>SQL</acronym> identifier
567
+ Some commands take an <acronym>SQL</acronym> identifier
568
568
(such as a table name) as argument. These arguments follow the
569
569
syntax rules of <acronym>SQL</acronym> regarding double quotes: an
570
- identifier without double quotes is coerced to lower-case. For all
571
- other commands double quotes are not special and will become part of
572
- the argument.
570
+ identifier without double quotes is coerced to lower-case, while
571
+ whitespace within double quotes is included in the argument.
573
572
</para>
574
573
575
574
<para>
@@ -732,18 +731,17 @@ testdb=>
732
731
</varlistentry>
733
732
734
733
<varlistentry>
735
- <term><literal>\d</literal> <replaceable class="parameter">relation </replaceable> </term>
734
+ <term><literal>\d</literal> [ <replaceable class="parameter">pattern </replaceable> ] </term>
736
735
737
736
<listitem>
738
737
<para>
739
- Shows all columns of <replaceable
740
- class="parameter">relation </replaceable> (which could be a
741
- table, view, index, or sequence) , their types, and any special
738
+ For each relation (table, view, index, or sequence) matching the
739
+ <replaceable class="parameter">pattern </replaceable>, show all
740
+ columns , their types, and any special
742
741
attributes such as <literal>NOT NULL</literal> or defaults, if
743
- any. If the relation is, in fact, a table, any defined indices,
744
- primary keys, unique constraints and check constraints are also
745
- listed. If the relation is a view, the view definition is also
746
- shown.
742
+ any. Associated indexes, constraints, rules, and triggers are
743
+ also shown, as is the view definition if the relation is a view.
744
+ (<quote>Matching the pattern</> is defined below.)
747
745
</para>
748
746
749
747
<para>
@@ -753,7 +751,8 @@ testdb=>
753
751
754
752
<note>
755
753
<para>
756
- If <command>\d</command> is called without any arguments, it is
754
+ If <command>\d</command> is used without a
755
+ <replaceable class="parameter">pattern</replaceable> argument, it is
757
756
equivalent to <command>\dtvs</command> which will show a list of
758
757
all tables, views, and sequences. This is purely a convenience
759
758
measure.
@@ -776,34 +775,35 @@ testdb=>
776
775
</varlistentry>
777
776
778
777
<varlistentry>
779
- <term><literal>\dd</literal> [ <replaceable class="parameter">object </replaceable> ]</term>
778
+ <term><literal>\dd</literal> [ <replaceable class="parameter">pattern </replaceable> ]</term>
780
779
<listitem>
781
780
<para>
782
- Shows the descriptions of <replaceable
783
- class="parameter">object</replaceable> (which can be a regular
784
- expression), or of all objects if no argument is given.
781
+ Shows the descriptions of objects matching the <replaceable
782
+ class="parameter">pattern</replaceable>, or of all visible objects if
783
+ no argument is given. But in either case, only objects that have
784
+ a description are listed.
785
785
(<quote>Object</quote> covers aggregates, functions, operators,
786
786
types, relations (tables, views, indexes, sequences, large
787
787
objects), rules, and triggers.) For example:
788
788
<programlisting>
789
789
=> <userinput>\dd version</userinput>
790
- Object descriptions
791
- Name | What | Description
792
- ---------+----------+---------------------------
793
- version | function | PostgreSQL version string
790
+ Object descriptions
791
+ Schema | Name | Object | Description
792
+ ------------+--------- +----------+---------------------------
793
+ pg_catalog | version | function | PostgreSQL version string
794
794
(1 row)
795
795
</programlisting>
796
796
</para>
797
797
798
798
<para>
799
- Descriptions for objects can be generated with the
799
+ Descriptions for objects can be created with the
800
800
<command>COMMENT ON</command> <acronym>SQL</acronym> command.
801
801
</para>
802
802
803
803
<note>
804
804
<para>
805
805
<productname>PostgreSQL</productname> stores the object
806
- descriptions in the pg_description system table.
806
+ descriptions in the <structname> pg_description</> system table.
807
807
</para>
808
808
</note>
809
809
@@ -816,7 +816,7 @@ testdb=>
816
816
<listitem>
817
817
<para>
818
818
Lists all available domains (derived types). If <replaceable
819
- class="parameter">pattern</replaceable> (a regular expression)
819
+ class="parameter">pattern</replaceable>
820
820
is specified, only matching domains are shown.
821
821
</para>
822
822
</listitem>
@@ -830,7 +830,7 @@ testdb=>
830
830
<para>
831
831
Lists available functions, together with their argument and
832
832
return types. If <replaceable
833
- class="parameter">pattern</replaceable> (a regular expression)
833
+ class="parameter">pattern</replaceable>
834
834
is specified, only matching functions are shown. If the form
835
835
<literal>\df+</literal> is used, additional information about
836
836
each function, including language and description, is shown.
@@ -844,18 +844,17 @@ testdb=>
844
844
845
845
<listitem>
846
846
<para>
847
- This is not the actual command name: The letters i, s, t, v, S
847
+ This is not the actual command name: the letters i, s, t, v, S
848
848
stand for index, sequence, table, view, and system table,
849
- respectively. You can specify any or all of them in any order to
850
- obtain a listing of them, together with who the owner is.
849
+ respectively. You can specify any or all of these letters, in any
850
+ order, to obtain a listing of all the matching objects.
851
+ If <quote>+</quote> is appended to the command name, each object is
852
+ listed with its associated description, if any.
851
853
</para>
852
854
853
855
<para>
854
- If <replaceable class="parameter">pattern</replaceable> is
855
- specified, it is a regular expression that restricts the listing
856
- to those objects whose name matches. If one appends a
857
- <quote>+</quote> to the command name, each object is listed with
858
- its associated description, if any.
856
+ If a <replaceable class="parameter">pattern</replaceable> is
857
+ specified, only objects whose name matches the pattern are listed.
859
858
</para>
860
859
</listitem>
861
860
</varlistentry>
@@ -873,12 +872,12 @@ testdb=>
873
872
874
873
875
874
<varlistentry>
876
- <term><literal>\do [ <replaceable class="parameter">name </replaceable> ]</literal></term>
875
+ <term><literal>\do [ <replaceable class="parameter">pattern </replaceable> ]</literal></term>
877
876
<listitem>
878
877
<para>
879
878
Lists available operators with their operand and return types.
880
- If <replaceable class="parameter">name </replaceable> is
881
- specified, only operators with that name will be shown .
879
+ If a <replaceable class="parameter">pattern </replaceable> is
880
+ specified, only operators whose name matches the pattern are listed .
882
881
</para>
883
882
</listitem>
884
883
</varlistentry>
@@ -888,9 +887,17 @@ testdb=>
888
887
<term><literal>\dp</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
889
888
<listitem>
890
889
<para>
891
- This is an alias for <command>\z</command> which was included
892
- for its greater mnemonic value (<quote>display
893
- permissions</quote>).
890
+ Produces a list of all available tables with their
891
+ associated access permissions.
892
+ If a <replaceable class="parameter">pattern</replaceable> is
893
+ specified, only tables whose name matches the pattern are listed.
894
+ </para>
895
+
896
+ <para>
897
+ The commands <xref linkend="SQL-GRANT"> and
898
+ <xref linkend="SQL-REVOKE">
899
+ are used to set access permissions. See <xref linkend="SQL-GRANT">
900
+ for more information.
894
901
</para>
895
902
</listitem>
896
903
</varlistentry>
@@ -912,7 +919,7 @@ testdb=>
912
919
<term><literal>\du [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
913
920
<listitem>
914
921
<para>
915
- Lists all configured users or only those that match <replaceable
922
+ Lists all database users, or only those that match <replaceable
916
923
class="parameter">pattern</replaceable>.
917
924
</para>
918
925
</listitem>
@@ -1608,57 +1615,23 @@ lo_import 152801
1608
1615
<term><literal>\z</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
1609
1616
<listitem>
1610
1617
<para>
1611
- Produces a list of all tables in the database with their
1612
- appropriate access permissions listed. If an argument is given
1613
- it is taken as a regular expression which limits the listing to
1614
- those tables which match it.
1615
- </para>
1616
-
1617
- <para>
1618
- <programlisting>
1619
- test=> <userinput>\z</userinput>
1620
- Access permissions for database "test"
1621
- Relation | Access permissions
1622
- ----------+-------------------------------------
1623
- my_table | {"=r","joe=arwR", "group staff=ar"}
1624
- (1 row )
1625
- </programlisting>
1626
- Read this as follows:
1627
-
1628
- <itemizedlist>
1629
- <listitem>
1630
- <para>
1631
- <literal>"=r"</literal>: <literal>PUBLIC</literal> has read
1632
- (<command>SELECT</command>) permission on the table.
1633
- </para>
1634
- </listitem>
1635
-
1636
- <listitem>
1637
- <para>
1638
- <literal>"joe=arwR"</literal>: User <literal>joe</literal> has
1639
- read, write (<command>UPDATE</command>,
1640
- <command>DELETE</command>), <quote>append</quote>
1641
- (<command>INSERT</command>) permissions, and permission to
1642
- create rules on the table.
1643
- </para>
1644
- </listitem>
1645
-
1646
- <listitem>
1647
- <para>
1648
- <literal>"group staff=ar"</literal>: Group
1649
- <literal>staff</literal> has <command>SELECT</command> and
1650
- <command>INSERT</command> permission.
1651
- </para>
1652
- </listitem>
1653
- </itemizedlist>
1618
+ Produces a list of all available tables with their
1619
+ associated access permissions.
1620
+ If a <replaceable class="parameter">pattern</replaceable> is
1621
+ specified, only tables whose name matches the pattern are listed.
1654
1622
</para>
1655
1623
1656
1624
<para>
1657
1625
The commands <xref linkend="SQL-GRANT"> and
1658
1626
<xref linkend="SQL-REVOKE">
1659
- are used to set access permissions.
1627
+ are used to set access permissions. See <xref linkend="SQL-GRANT">
1628
+ for more information.
1660
1629
</para>
1661
1630
1631
+ <para>
1632
+ This is an alias for <command>\dp</command> (<quote>display
1633
+ permissions</quote>).
1634
+ </para>
1662
1635
</listitem>
1663
1636
</varlistentry>
1664
1637
@@ -1688,6 +1661,46 @@ Access permissions for database "test"
1688
1661
1689
1662
</variablelist>
1690
1663
</para>
1664
+
1665
+ <para>
1666
+ The various <literal>\d</> commands accept a <replaceable
1667
+ class="parameter">pattern</replaceable> parameter to specify the
1668
+ object name(s) to be displayed. Patterns are interpreted similarly
1669
+ to SQL identifiers, in that unquoted letters are forced to lowercase,
1670
+ while double quotes (<literal>"</>) protect letters from case conversion
1671
+ and allow incorporation of whitespace into the identifier. Within
1672
+ double quotes, paired double quotes reduce to a single double quote in
1673
+ the resulting name. For example, <literal>FOO"BAR"BAZ</> is interpreted
1674
+ as <literal>fooBARbaz</>, and <literal>"A weird"" name"</> becomes
1675
+ <literal>A weird" name</>.
1676
+ </para>
1677
+
1678
+ <para>
1679
+ More interestingly, <literal>\d</> patterns allow the use of
1680
+ <literal>*</> to mean <quote>any sequence of characters</>, and
1681
+ <literal>?</> to mean <quote>any single character</>. (This notation
1682
+ is comparable to Unix shell filename patterns.) Advanced users can
1683
+ also use regular-expression notations such as character classes, for
1684
+ example <literal>[0-9]</> to match <quote>any digit</>. To make any of
1685
+ these pattern-matching characters be interpreted literally, surround it
1686
+ with double quotes.
1687
+ </para>
1688
+
1689
+ <para>
1690
+ A pattern that contains an (unquoted) dot is interpreted as a schema
1691
+ name pattern followed by an object name pattern. For example,
1692
+ <literal> \dt foo*.bar*</> displays all tables in schemas whose name
1693
+ starts with <literal>foo</> and whose table name
1694
+ starts with <literal>bar</>. If no dot appears, then the pattern
1695
+ matches only objects that are visible in the current schema search path.
1696
+ </para>
1697
+
1698
+ <para>
1699
+ Whenever the <replaceable class="parameter">pattern</replaceable> parameter
1700
+ is omitted completely, the <literal>\d</> commands display all objects
1701
+ that are visible in the current schema search path. To see all objects
1702
+ in the database, use the pattern <literal>*.*</>.
1703
+ </para>
1691
1704
</refsect2>
1692
1705
1693
1706
<refsect2>
@@ -2402,11 +2415,12 @@ $ ./configure --with-includes=/opt/gnu/include --with-libs=/opt/gnu/lib ...
2402
2415
<itemizedlist>
2403
2416
<listitem>
2404
2417
<para>
2405
- In some earlier life <application>psql</application> allowed the
2406
- first argument to start directly after the (single-letter)
2407
- command. For compatibility this is still supported to some extent
2418
+ In an earlier life <application>psql</application> allowed the
2419
+ first argument of a single-letter backslash command to start
2420
+ directly after the command, without intervening whitespace. For
2421
+ compatibility this is still supported to some extent,
2408
2422
but I am not going to explain the details here as this use is
2409
- discouraged. But if you get strange messages, keep this in mind.
2423
+ discouraged. If you get strange messages, keep this in mind.
2410
2424
For example
2411
2425
<programlisting>
2412
2426
testdb=> <userinput>\foo</userinput>
@@ -2421,7 +2435,8 @@ Field separator is "oo",
2421
2435
<application>psql</application> only works smoothly with servers
2422
2436
of the same version. That does not mean other combinations will
2423
2437
fail outright, but subtle and not-so-subtle problems might come
2424
- up.
2438
+ up. Backslash commands are particularly likely to fail if the
2439
+ server is of a different version.
2425
2440
</para>
2426
2441
</listitem>
2427
2442
0 commit comments