From 1ff01b3902cbf5b22d1a439014202499c21b2994 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 19 Oct 2017 21:16:39 -0400
Subject: [PATCH] Convert SGML IDs to lower case

IDs in SGML are case insensitive, and we have accumulated a mix of upper
and lower case IDs, including different variants of the same ID.  In
XML, these will be case sensitive, so we need to fix up those
differences.  Going to all lower case seems most straightforward, and
the current build process already makes all anchors and lower case
anyway during the SGML->XML conversion, so this doesn't create any
difference in the output right now.  A future XML-only build process
would, however, maintain any mixed case ID spellings in the output, so
that is another reason to clean this up beforehand.

Author: Alexander Lakhin <exclusion@gmail.com>
---
 doc/src/sgml/acronyms.sgml                    |   6 +-
 doc/src/sgml/arch-dev.sgml                    |   2 +-
 doc/src/sgml/biblio.sgml                      |  40 ++---
 doc/src/sgml/brin.sgml                        |   2 +-
 doc/src/sgml/btree-gist.sgml                  |   4 +-
 doc/src/sgml/config.sgml                      |  18 +-
 doc/src/sgml/dblink.sgml                      |  38 ++---
 doc/src/sgml/ddl.sgml                         |   2 +-
 doc/src/sgml/ecpg.sgml                        |  70 ++++----
 doc/src/sgml/func.sgml                        |   4 +-
 doc/src/sgml/geqo.sgml                        |   4 +-
 doc/src/sgml/gin.sgml                         |   2 +-
 doc/src/sgml/gist.sgml                        |   2 +-
 doc/src/sgml/history.sgml                     |  14 +-
 doc/src/sgml/indices.sgml                     |  16 +-
 doc/src/sgml/libpq.sgml                       |   2 +-
 doc/src/sgml/lobj.sgml                        |   2 +-
 doc/src/sgml/logical-replication.sgml         |   2 +-
 doc/src/sgml/logicaldecoding.sgml             |   6 +-
 doc/src/sgml/mvcc.sgml                        |   4 +-
 doc/src/sgml/passwordcheck.sgml               |   4 +-
 doc/src/sgml/perform.sgml                     |   2 +-
 doc/src/sgml/queries.sgml                     |   2 +-
 doc/src/sgml/query.sgml                       |   2 +-
 doc/src/sgml/rangetypes.sgml                  |   6 +-
 doc/src/sgml/ref/abort.sgml                   |   6 +-
 doc/src/sgml/ref/alter_aggregate.sgml         |   2 +-
 doc/src/sgml/ref/alter_collation.sgml         |   2 +-
 doc/src/sgml/ref/alter_conversion.sgml        |   2 +-
 doc/src/sgml/ref/alter_database.sgml          |   2 +-
 .../sgml/ref/alter_default_privileges.sgml    |   2 +-
 doc/src/sgml/ref/alter_domain.sgml            |   8 +-
 doc/src/sgml/ref/alter_event_trigger.sgml     |   2 +-
 doc/src/sgml/ref/alter_extension.sgml         |   4 +-
 .../sgml/ref/alter_foreign_data_wrapper.sgml  |   2 +-
 doc/src/sgml/ref/alter_foreign_table.sgml     |   8 +-
 doc/src/sgml/ref/alter_function.sgml          |   2 +-
 doc/src/sgml/ref/alter_group.sgml             |   6 +-
 doc/src/sgml/ref/alter_index.sgml             |  10 +-
 doc/src/sgml/ref/alter_language.sgml          |   2 +-
 doc/src/sgml/ref/alter_large_object.sgml      |   2 +-
 doc/src/sgml/ref/alter_materialized_view.sgml |   2 +-
 doc/src/sgml/ref/alter_opclass.sgml           |   2 +-
 doc/src/sgml/ref/alter_operator.sgml          |   2 +-
 doc/src/sgml/ref/alter_opfamily.sgml          |   2 +-
 doc/src/sgml/ref/alter_policy.sgml            |   2 +-
 doc/src/sgml/ref/alter_publication.sgml       |   4 +-
 doc/src/sgml/ref/alter_role.sgml              |  16 +-
 doc/src/sgml/ref/alter_rule.sgml              |   2 +-
 doc/src/sgml/ref/alter_schema.sgml            |   2 +-
 doc/src/sgml/ref/alter_sequence.sgml          |   2 +-
 doc/src/sgml/ref/alter_server.sgml            |   2 +-
 doc/src/sgml/ref/alter_statistics.sgml        |   2 +-
 doc/src/sgml/ref/alter_subscription.sgml      |   8 +-
 doc/src/sgml/ref/alter_system.sgml            |   6 +-
 doc/src/sgml/ref/alter_table.sgml             |  30 ++--
 doc/src/sgml/ref/alter_tablespace.sgml        |   2 +-
 doc/src/sgml/ref/alter_trigger.sgml           |   4 +-
 doc/src/sgml/ref/alter_tsconfig.sgml          |   2 +-
 doc/src/sgml/ref/alter_tsdictionary.sgml      |   2 +-
 doc/src/sgml/ref/alter_tsparser.sgml          |   2 +-
 doc/src/sgml/ref/alter_tstemplate.sgml        |   2 +-
 doc/src/sgml/ref/alter_type.sgml              |   6 +-
 doc/src/sgml/ref/alter_user.sgml              |   2 +-
 doc/src/sgml/ref/alter_user_mapping.sgml      |   2 +-
 doc/src/sgml/ref/alter_view.sgml              |   2 +-
 doc/src/sgml/ref/analyze.sgml                 |   2 +-
 doc/src/sgml/ref/begin.sgml                   |   6 +-
 doc/src/sgml/ref/close.sgml                   |   2 +-
 doc/src/sgml/ref/cluster.sgml                 |   4 +-
 doc/src/sgml/ref/clusterdb.sgml               |   8 +-
 doc/src/sgml/ref/comment.sgml                 |   2 +-
 doc/src/sgml/ref/commit.sgml                  |   4 +-
 doc/src/sgml/ref/commit_prepared.sgml         |   2 +-
 doc/src/sgml/ref/copy.sgml                    |   4 +-
 doc/src/sgml/ref/create_aggregate.sgml        |   2 +-
 doc/src/sgml/ref/create_cast.sgml             |   2 +-
 doc/src/sgml/ref/create_collation.sgml        |   2 +-
 doc/src/sgml/ref/create_conversion.sgml       |   2 +-
 doc/src/sgml/ref/create_database.sgml         |   8 +-
 doc/src/sgml/ref/create_domain.sgml           |   6 +-
 doc/src/sgml/ref/create_event_trigger.sgml    |   2 +-
 doc/src/sgml/ref/create_extension.sgml        |   2 +-
 .../sgml/ref/create_foreign_data_wrapper.sgml |   2 +-
 doc/src/sgml/ref/create_foreign_table.sgml    |  12 +-
 doc/src/sgml/ref/create_function.sgml         |   4 +-
 doc/src/sgml/ref/create_group.sgml            |   2 +-
 doc/src/sgml/ref/create_index.sgml            |  16 +-
 doc/src/sgml/ref/create_language.sgml         |   2 +-
 .../sgml/ref/create_materialized_view.sgml    |   2 +-
 doc/src/sgml/ref/create_opclass.sgml          |   2 +-
 doc/src/sgml/ref/create_operator.sgml         |   2 +-
 doc/src/sgml/ref/create_opfamily.sgml         |   2 +-
 doc/src/sgml/ref/create_policy.sgml           |  12 +-
 doc/src/sgml/ref/create_publication.sgml      |   2 +-
 doc/src/sgml/ref/create_role.sgml             |  16 +-
 doc/src/sgml/ref/create_rule.sgml             |   2 +-
 doc/src/sgml/ref/create_schema.sgml           |   2 +-
 doc/src/sgml/ref/create_sequence.sgml         |   2 +-
 doc/src/sgml/ref/create_server.sgml           |   2 +-
 doc/src/sgml/ref/create_statistics.sgml       |   6 +-
 doc/src/sgml/ref/create_subscription.sgml     |   2 +-
 doc/src/sgml/ref/create_table.sgml            |  26 +--
 doc/src/sgml/ref/create_table_as.sgml         |   2 +-
 doc/src/sgml/ref/create_tablespace.sgml       |   2 +-
 doc/src/sgml/ref/create_transform.sgml        |   2 +-
 doc/src/sgml/ref/create_trigger.sgml          |  12 +-
 doc/src/sgml/ref/create_tsconfig.sgml         |   2 +-
 doc/src/sgml/ref/create_tsdictionary.sgml     |   2 +-
 doc/src/sgml/ref/create_tsparser.sgml         |   2 +-
 doc/src/sgml/ref/create_tstemplate.sgml       |   2 +-
 doc/src/sgml/ref/create_type.sgml             |  12 +-
 doc/src/sgml/ref/create_user.sgml             |   2 +-
 doc/src/sgml/ref/create_user_mapping.sgml     |   2 +-
 doc/src/sgml/ref/create_view.sgml             |  10 +-
 doc/src/sgml/ref/createdb.sgml                |  12 +-
 doc/src/sgml/ref/createuser.sgml              |   8 +-
 doc/src/sgml/ref/deallocate.sgml              |   2 +-
 doc/src/sgml/ref/declare.sgml                 |   2 +-
 doc/src/sgml/ref/delete.sgml                  |   2 +-
 doc/src/sgml/ref/discard.sgml                 |   2 +-
 doc/src/sgml/ref/do.sgml                      |   2 +-
 doc/src/sgml/ref/drop_aggregate.sgml          |   2 +-
 doc/src/sgml/ref/drop_cast.sgml               |   2 +-
 doc/src/sgml/ref/drop_collation.sgml          |   2 +-
 doc/src/sgml/ref/drop_conversion.sgml         |   2 +-
 doc/src/sgml/ref/drop_database.sgml           |   2 +-
 doc/src/sgml/ref/drop_domain.sgml             |   8 +-
 doc/src/sgml/ref/drop_event_trigger.sgml      |   2 +-
 doc/src/sgml/ref/drop_extension.sgml          |   2 +-
 .../sgml/ref/drop_foreign_data_wrapper.sgml   |   2 +-
 doc/src/sgml/ref/drop_foreign_table.sgml      |   2 +-
 doc/src/sgml/ref/drop_function.sgml           |   6 +-
 doc/src/sgml/ref/drop_group.sgml              |   2 +-
 doc/src/sgml/ref/drop_index.sgml              |   2 +-
 doc/src/sgml/ref/drop_language.sgml           |   2 +-
 doc/src/sgml/ref/drop_materialized_view.sgml  |   2 +-
 doc/src/sgml/ref/drop_opclass.sgml            |   2 +-
 doc/src/sgml/ref/drop_operator.sgml           |   2 +-
 doc/src/sgml/ref/drop_opfamily.sgml           |   2 +-
 doc/src/sgml/ref/drop_owned.sgml              |   2 +-
 doc/src/sgml/ref/drop_policy.sgml             |   2 +-
 doc/src/sgml/ref/drop_publication.sgml        |   2 +-
 doc/src/sgml/ref/drop_role.sgml               |   4 +-
 doc/src/sgml/ref/drop_rule.sgml               |   2 +-
 doc/src/sgml/ref/drop_schema.sgml             |   2 +-
 doc/src/sgml/ref/drop_sequence.sgml           |   2 +-
 doc/src/sgml/ref/drop_server.sgml             |   2 +-
 doc/src/sgml/ref/drop_statistics.sgml         |   2 +-
 doc/src/sgml/ref/drop_subscription.sgml       |   2 +-
 doc/src/sgml/ref/drop_table.sgml              |   2 +-
 doc/src/sgml/ref/drop_tablespace.sgml         |   2 +-
 doc/src/sgml/ref/drop_transform.sgml          |   2 +-
 doc/src/sgml/ref/drop_trigger.sgml            |   6 +-
 doc/src/sgml/ref/drop_tsconfig.sgml           |   2 +-
 doc/src/sgml/ref/drop_tsdictionary.sgml       |   2 +-
 doc/src/sgml/ref/drop_tsparser.sgml           |   2 +-
 doc/src/sgml/ref/drop_tstemplate.sgml         |   2 +-
 doc/src/sgml/ref/drop_type.sgml               |   8 +-
 doc/src/sgml/ref/drop_user.sgml               |   2 +-
 doc/src/sgml/ref/drop_user_mapping.sgml       |   2 +-
 doc/src/sgml/ref/drop_view.sgml               |   2 +-
 doc/src/sgml/ref/dropdb.sgml                  |   8 +-
 doc/src/sgml/ref/dropuser.sgml                |   8 +-
 doc/src/sgml/ref/ecpg-ref.sgml                |   4 +-
 doc/src/sgml/ref/end.sgml                     |   4 +-
 doc/src/sgml/ref/execute.sgml                 |   2 +-
 doc/src/sgml/ref/explain.sgml                 |   2 +-
 doc/src/sgml/ref/fetch.sgml                   |   2 +-
 doc/src/sgml/ref/grant.sgml                   |   4 +-
 doc/src/sgml/ref/import_foreign_schema.sgml   |   8 +-
 doc/src/sgml/ref/initdb.sgml                  |   4 +-
 doc/src/sgml/ref/insert.sgml                  |   8 +-
 doc/src/sgml/ref/listen.sgml                  |   2 +-
 doc/src/sgml/ref/load.sgml                    |   2 +-
 doc/src/sgml/ref/lock.sgml                    |   4 +-
 doc/src/sgml/ref/move.sgml                    |   2 +-
 doc/src/sgml/ref/notify.sgml                  |   2 +-
 doc/src/sgml/ref/pg_basebackup.sgml           |   4 +-
 doc/src/sgml/ref/pg_controldata.sgml          |   4 +-
 doc/src/sgml/ref/pg_ctl-ref.sgml              |  10 +-
 doc/src/sgml/ref/pg_dump.sgml                 |   8 +-
 doc/src/sgml/ref/pg_dumpall.sgml              |   2 +-
 doc/src/sgml/ref/pg_receivewal.sgml           |   2 +-
 doc/src/sgml/ref/pg_recvlogical.sgml          |   2 +-
 doc/src/sgml/ref/pg_resetwal.sgml             |   4 +-
 doc/src/sgml/ref/pg_restore.sgml              |   2 +-
 doc/src/sgml/ref/pg_waldump.sgml              |   2 +-
 doc/src/sgml/ref/prepare.sgml                 |   4 +-
 doc/src/sgml/ref/prepare_transaction.sgml     |   2 +-
 doc/src/sgml/ref/psql-ref.sgml                | 156 +++++++++---------
 doc/src/sgml/ref/reassign_owned.sgml          |   2 +-
 .../sgml/ref/refresh_materialized_view.sgml   |   4 +-
 doc/src/sgml/ref/reindex.sgml                 |   2 +-
 doc/src/sgml/ref/reindexdb.sgml               |   8 +-
 doc/src/sgml/ref/release_savepoint.sgml       |   2 +-
 doc/src/sgml/ref/reset.sgml                   |   6 +-
 doc/src/sgml/ref/revoke.sgml                  |  10 +-
 doc/src/sgml/ref/rollback.sgml                |   4 +-
 doc/src/sgml/ref/rollback_prepared.sgml       |   2 +-
 doc/src/sgml/ref/rollback_to.sgml             |   4 +-
 doc/src/sgml/ref/savepoint.sgml               |   6 +-
 doc/src/sgml/ref/security_label.sgml          |   2 +-
 doc/src/sgml/ref/select.sgml                  |  28 ++--
 doc/src/sgml/ref/select_into.sgml             |   2 +-
 doc/src/sgml/ref/set.sgml                     |   6 +-
 doc/src/sgml/ref/set_constraints.sgml         |   2 +-
 doc/src/sgml/ref/set_role.sgml                |   4 +-
 doc/src/sgml/ref/set_session_auth.sgml        |   4 +-
 doc/src/sgml/ref/set_transaction.sgml         |   4 +-
 doc/src/sgml/ref/show.sgml                    |   8 +-
 doc/src/sgml/ref/start_transaction.sgml       |   2 +-
 doc/src/sgml/ref/truncate.sgml                |   2 +-
 doc/src/sgml/ref/unlisten.sgml                |   2 +-
 doc/src/sgml/ref/update.sgml                  |   2 +-
 doc/src/sgml/ref/vacuum.sgml                  |   2 +-
 doc/src/sgml/ref/vacuumdb.sgml                |   8 +-
 doc/src/sgml/ref/values.sgml                  |   2 +-
 doc/src/sgml/release-10.sgml                  |  46 +++---
 doc/src/sgml/release-8.2.sgml                 |  94 +++++------
 doc/src/sgml/release-8.3.sgml                 |   4 +-
 doc/src/sgml/release-9.0.sgml                 |  86 +++++-----
 doc/src/sgml/release-9.1.sgml                 |  78 ++++-----
 doc/src/sgml/release-9.2.sgml                 |  64 +++----
 doc/src/sgml/release-9.3.sgml                 |  86 +++++-----
 doc/src/sgml/release-9.4.sgml                 |  82 ++++-----
 doc/src/sgml/release-9.5.sgml                 |  90 +++++-----
 doc/src/sgml/release-9.6.sgml                 |  12 +-
 doc/src/sgml/rules.sgml                       |   4 +-
 doc/src/sgml/spgist.sgml                      |   2 +-
 doc/src/sgml/start.sgml                       |   2 +-
 doc/src/sgml/tablefunc.sgml                   |   2 +-
 doc/src/sgml/xfunc.sgml                       |   4 +-
 doc/src/sgml/xindex.sgml                      |   6 +-
 234 files changed, 925 insertions(+), 925 deletions(-)

diff --git a/doc/src/sgml/acronyms.sgml b/doc/src/sgml/acronyms.sgml
index 35514d4d9ac..6e9fddf404e 100644
--- a/doc/src/sgml/acronyms.sgml
+++ b/doc/src/sgml/acronyms.sgml
@@ -232,7 +232,7 @@
     <term><acronym>GIN</acronym></term>
     <listitem>
      <para>
-      <link linkend="GIN">Generalized Inverted Index</link>
+      <link linkend="gin">Generalized Inverted Index</link>
      </para>
     </listitem>
    </varlistentry>
@@ -241,7 +241,7 @@
     <term><acronym>GiST</acronym></term>
     <listitem>
      <para>
-      <link linkend="GiST">Generalized Search Tree</link>
+      <link linkend="gist">Generalized Search Tree</link>
      </para>
     </listitem>
    </varlistentry>
@@ -583,7 +583,7 @@
     <term><acronym>SP-GiST</acronym></term>
     <listitem>
      <para>
-      <link linkend="SPGiST">Space-Partitioned Generalized Search Tree</link>
+      <link linkend="spgist">Space-Partitioned Generalized Search Tree</link>
      </para>
     </listitem>
    </varlistentry>
diff --git a/doc/src/sgml/arch-dev.sgml b/doc/src/sgml/arch-dev.sgml
index 5423aadb9c8..d49901c6900 100644
--- a/doc/src/sgml/arch-dev.sgml
+++ b/doc/src/sgml/arch-dev.sgml
@@ -7,7 +7,7 @@
    <title>Author</title>
    <para>
     This chapter originated as part of
-    <xref linkend="SIM98">, Stefan Simkovics'
+    <xref linkend="sim98">, Stefan Simkovics'
     Master's Thesis prepared at Vienna University of Technology under the direction
     of O.Univ.Prof.Dr. Georg Gottlob and Univ.Ass. Mag. Katrin Seyr.
    </para>
diff --git a/doc/src/sgml/biblio.sgml b/doc/src/sgml/biblio.sgml
index d7547e6e921..49530241620 100644
--- a/doc/src/sgml/biblio.sgml
+++ b/doc/src/sgml/biblio.sgml
@@ -18,7 +18,7 @@
   <bibliodiv>
    <title><acronym>SQL</acronym> Reference Books</title>
 
-   <biblioentry id="BOWMAN01">
+   <biblioentry id="bowman01">
     <title>The Practical <acronym>SQL</acronym> Handbook</title>
     <subtitle>Using SQL Variants</subtitle>
     <edition>Fourth Edition</edition>
@@ -43,7 +43,7 @@
     <pubdate>2001</pubdate>
    </biblioentry>
 
-   <biblioentry id="DATE97">
+   <biblioentry id="date97">
     <title>A Guide to the <acronym>SQL</acronym> Standard</title>
     <subtitle>A user's guide to the standard database language <acronym>SQL</acronym></subtitle>
     <edition>Fourth Edition</edition>
@@ -64,7 +64,7 @@
     <pubdate>1997</pubdate>
    </biblioentry>
 
-   <biblioentry id="DATE04">
+   <biblioentry id="date04">
     <title>An Introduction to Database Systems</title>
     <edition>Eighth Edition</edition>
     <authorgroup>
@@ -80,7 +80,7 @@
     <pubdate>2003</pubdate>
    </biblioentry>
 
-  <biblioentry id="ELMA04">
+  <biblioentry id="elma04">
    <title>Fundamentals of Database Systems</title>
    <edition>Fourth Edition</edition>
    <authorgroup>
@@ -100,7 +100,7 @@
    <pubdate>2003</pubdate>
   </biblioentry>
 
-   <biblioentry id="MELT93">
+   <biblioentry id="melt93">
     <title>Understanding the New <acronym>SQL</acronym></title>
     <subtitle>A complete guide</subtitle>
     <authorgroup>
@@ -120,7 +120,7 @@
     <pubdate>1993</pubdate>
    </biblioentry>
 
-   <biblioentry id="ULL88">
+   <biblioentry id="ull88">
     <title>Principles of Database and Knowledge</title>
     <subtitle>Base Systems</subtitle>
     <authorgroup>
@@ -141,7 +141,7 @@
   <bibliodiv>
    <title>PostgreSQL-specific Documentation</title>
 
-   <biblioentry id="SIM98">
+   <biblioentry id="sim98">
     <title>Enhancement of the ANSI SQL Implementation of PostgreSQL</title>
     <authorgroup>
      <author>
@@ -185,7 +185,7 @@ ssimkovi@ag.or.at
     <pubdate>November 29, 1998</pubdate>
    </biblioentry>
 
-   <biblioentry id="YU95">
+   <biblioentry id="yu95">
     <title>The <productname>Postgres95</productname> User Manual</title>
     <authorgroup>
      <author>
@@ -204,7 +204,7 @@ ssimkovi@ag.or.at
     <pubdate>Sept. 5, 1995</pubdate>
    </biblioentry>
 
-  <biblioentry id="FONG">
+  <biblioentry id="fong">
    <title><ulink url="http://db.cs.berkeley.edu/papers/UCB-MS-zfong.pdf">The
    design and implementation of the <productname>POSTGRES</productname> query
    optimizer</ulink></title>
@@ -222,7 +222,7 @@ ssimkovi@ag.or.at
   <bibliodiv>
    <title>Proceedings and Articles</title>
 
-   <biblioentry id="OLSON93">
+   <biblioentry id="olson93">
     <title>Partial indexing in POSTGRES: research project</title>
     <authorgroup>
      <author>
@@ -238,7 +238,7 @@ ssimkovi@ag.or.at
     <pubdate>1993</pubdate>
    </biblioentry>
 
-   <biblioentry id="ONG90">
+   <biblioentry id="ong90">
    <biblioset relation="article">
     <title>A Unified Framework for Version Modeling Using Production Rules in a Database System</title>
     <authorgroup>
@@ -262,7 +262,7 @@ ssimkovi@ag.or.at
    </biblioset>
    </biblioentry>
 
-   <biblioentry id="ROWE87">
+   <biblioentry id="rowe87">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M87-13.pdf">The <productname>POSTGRES</productname>
     data model</ulink></title>
@@ -284,7 +284,7 @@ ssimkovi@ag.or.at
     </confgroup>
    </biblioentry>
 
-   <biblioentry id="SESHADRI95">
+   <biblioentry id="seshadri95">
    <biblioset relation="article">
     <title><ulink url="http://citeseer.ist.psu.edu/seshadri95generalized.html">Generalized
     Partial Indexes</ulink></title>
@@ -313,7 +313,7 @@ ssimkovi@ag.or.at
     <pagenums>420-7</pagenums>
    </biblioentry>
 
-   <biblioentry id="STON86">
+   <biblioentry id="ston86">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M85-95.pdf">The
     design of <productname>POSTGRES</productname></ulink></title>
@@ -335,7 +335,7 @@ ssimkovi@ag.or.at
     </confgroup>
    </biblioentry>
 
-   <biblioentry id="STON87a">
+   <biblioentry id="ston87a">
    <biblioset relation="article">
     <title>The design of the <productname>POSTGRES</productname> rules system</title>
     <authorgroup>
@@ -360,7 +360,7 @@ ssimkovi@ag.or.at
     </confgroup>
    </biblioentry>
 
-   <biblioentry id="STON87b">
+   <biblioentry id="ston87b">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M87-06.pdf">The
     design of the <productname>POSTGRES</productname> storage
@@ -379,7 +379,7 @@ ssimkovi@ag.or.at
     </confgroup>
    </biblioentry>
 
-   <biblioentry id="STON89">
+   <biblioentry id="ston89">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M89-82.pdf">A
     commentary on the <productname>POSTGRES</productname> rules
@@ -405,7 +405,7 @@ ssimkovi@ag.or.at
    </biblioset>
    </biblioentry>
 
-   <biblioentry id="STON89b">
+   <biblioentry id="ston89b">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M89-17.pdf">The
     case for partial indexes</ulink></title>
@@ -423,7 +423,7 @@ ssimkovi@ag.or.at
    </biblioset>
    </biblioentry>
 
-   <biblioentry id="STON90a">
+   <biblioentry id="ston90a">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M90-34.pdf">The
     implementation of <productname>POSTGRES</productname></ulink></title>
@@ -451,7 +451,7 @@ ssimkovi@ag.or.at
    </biblioset>
    </biblioentry>
 
-   <biblioentry id="STON90b">
+   <biblioentry id="ston90b">
    <biblioset relation="article">
     <title><ulink url="http://db.cs.berkeley.edu/papers/ERL-M90-36.pdf">On
     Rules, Procedures, Caching and Views in Database Systems</ulink></title>
diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml
index 91c01700ed5..b7483df4c08 100644
--- a/doc/src/sgml/brin.sgml
+++ b/doc/src/sgml/brin.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/brin.sgml -->
 
-<chapter id="BRIN">
+<chapter id="brin">
 <title>BRIN Indexes</title>
 
    <indexterm>
diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml
index dcb939f1fbf..774442feeee 100644
--- a/doc/src/sgml/btree-gist.sgml
+++ b/doc/src/sgml/btree-gist.sgml
@@ -36,7 +36,7 @@
   In addition to the typical B-tree search operators, <filename>btree_gist</filename>
   also provides index support for <literal>&lt;&gt;</literal> (<quote>not
   equals</quote>). This may be useful in combination with an
-  <link linkend="SQL-CREATETABLE-EXCLUDE">exclusion constraint</link>,
+  <link linkend="sql-createtable-exclude">exclusion constraint</link>,
   as described below.
  </para>
 
@@ -70,7 +70,7 @@ SELECT *, a &lt;-&gt; 42 AS dist FROM test ORDER BY a &lt;-&gt; 42 LIMIT 10;
 </programlisting>
 
   <para>
-   Use an <link linkend="SQL-CREATETABLE-EXCLUDE">exclusion
+   Use an <link linkend="sql-createtable-exclude">exclusion
    constraint</link> to enforce the rule that a cage at a zoo
    can contain only one kind of animal:
   </para>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index aeda826d874..d360fc4d58a 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -170,7 +170,7 @@ shared_buffers = 128MB
      <filename>postgresql.auto.conf</filename><indexterm><primary>postgresql.auto.conf</primary></indexterm>,
      which has the same format as <filename>postgresql.conf</filename> but should
      never be edited manually.  This file holds settings provided through
-     the <xref linkend="SQL-ALTERSYSTEM"> command.  This file is automatically
+     the <xref linkend="sql-altersystem"> command.  This file is automatically
      read whenever <filename>postgresql.conf</filename> is, and its settings take
      effect in the same way.  Settings in <filename>postgresql.auto.conf</filename>
      override those in <filename>postgresql.conf</filename>.
@@ -191,7 +191,7 @@ shared_buffers = 128MB
      <para>
       <productname>PostgreSQL</productname> provides three SQL
       commands to establish configuration defaults.
-      The already-mentioned <xref linkend="SQL-ALTERSYSTEM"> command
+      The already-mentioned <xref linkend="sql-altersystem"> command
       provides a SQL-accessible means of changing global defaults; it is
       functionally equivalent to editing <filename>postgresql.conf</filename>.
       In addition, there are two commands that allow setting of defaults
@@ -232,7 +232,7 @@ shared_buffers = 128MB
     <itemizedlist>
      <listitem>
      <para>
-      The <xref linkend="SQL-SHOW"> command allows inspection of the
+      The <xref linkend="sql-show"> command allows inspection of the
       current value of all parameters.  The corresponding function is
       <function>current_setting(setting_name text)</function>.
      </para>
@@ -240,7 +240,7 @@ shared_buffers = 128MB
 
      <listitem>
       <para>
-       The <xref linkend="SQL-SET"> command allows modification of the
+       The <xref linkend="sql-set"> command allows modification of the
        current value of those parameters that can be set locally to a
        session; it has no effect on other sessions.
        The corresponding function is
@@ -266,7 +266,7 @@ shared_buffers = 128MB
 
      <listitem>
       <para>
-       Using <xref linkend="SQL-UPDATE"> on this view, specifically
+       Using <xref linkend="sql-update"> on this view, specifically
        updating the <structname>setting</structname> column, is the equivalent
        of issuing <command>SET</command> commands.  For example, the equivalent of
 <programlisting>
@@ -6237,7 +6237,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
 
        <para>
         For more information on row security policies,
-        see <xref linkend="SQL-CREATEPOLICY">.
+        see <xref linkend="sql-createpolicy">.
        </para>
       </listitem>
      </varlistentry>
@@ -7040,7 +7040,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
         This variable specifies one or more shared libraries that are to be
         preloaded at connection start.
         It contains a comma-separated list of library names, where each name
-        is interpreted as for the <xref linkend="SQL-LOAD"> command.
+        is interpreted as for the <xref linkend="sql-load"> command.
         Whitespace between entries is ignored; surround a library name with
         double quotes if you need to include whitespace or commas in the name.
         The parameter value only takes effect at the start of the connection.
@@ -7091,7 +7091,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
         This variable specifies one or more shared libraries that are to be
         preloaded at connection start.
         It contains a comma-separated list of library names, where each name
-        is interpreted as for the <xref linkend="SQL-LOAD"> command.
+        is interpreted as for the <xref linkend="sql-load"> command.
         Whitespace between entries is ignored; surround a library name with
         double quotes if you need to include whitespace or commas in the name.
         The parameter value only takes effect at the start of the connection.
@@ -7133,7 +7133,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
         This variable specifies one or more shared libraries to be preloaded at
         server start.
         It contains a comma-separated list of library names, where each name
-        is interpreted as for the <xref linkend="SQL-LOAD"> command.
+        is interpreted as for the <xref linkend="sql-load"> command.
         Whitespace between entries is ignored; surround a library name with
         double quotes if you need to include whitespace or commas in the name.
         This parameter can only be set at server start.  If a specified
diff --git a/doc/src/sgml/dblink.sgml b/doc/src/sgml/dblink.sgml
index 1f17d3ad2dc..12928e8bd38 100644
--- a/doc/src/sgml/dblink.sgml
+++ b/doc/src/sgml/dblink.sgml
@@ -18,7 +18,7 @@
   functionality using a more modern and standards-compliant infrastructure.
  </para>
 
- <refentry id="CONTRIB-DBLINK-CONNECT">
+ <refentry id="contrib-dblink-connect">
   <indexterm>
    <primary>dblink_connect</primary>
   </indexterm>
@@ -182,7 +182,7 @@ DROP SERVER fdtest;
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-CONNECT-U">
+ <refentry id="contrib-dblink-connect-u">
   <indexterm>
    <primary>dblink_connect_u</primary>
   </indexterm>
@@ -239,7 +239,7 @@ dblink_connect_u(text connname, text connstr) returns text
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-DISCONNECT">
+ <refentry id="contrib-dblink-disconnect">
   <indexterm>
    <primary>dblink_disconnect</primary>
   </indexterm>
@@ -314,7 +314,7 @@ SELECT dblink_disconnect('myconn');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-FUNCTION">
+ <refentry id="contrib-dblink-function">
   <indexterm>
    <primary>dblink</primary>
   </indexterm>
@@ -532,7 +532,7 @@ SELECT * FROM dblink('myconn', 'select proname, prosrc from pg_proc')
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-EXEC">
+ <refentry id="contrib-dblink-exec">
   <indexterm>
    <primary>dblink_exec</primary>
   </indexterm>
@@ -669,7 +669,7 @@ DETAIL:  ERROR:  null value in column "relnamespace" violates not-null constrain
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-OPEN">
+ <refentry id="contrib-dblink-open">
   <indexterm>
    <primary>dblink_open</primary>
   </indexterm>
@@ -793,7 +793,7 @@ SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-FETCH">
+ <refentry id="contrib-dblink-fetch">
   <indexterm>
    <primary>dblink_fetch</primary>
   </indexterm>
@@ -946,7 +946,7 @@ SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-CLOSE">
+ <refentry id="contrib-dblink-close">
   <indexterm>
    <primary>dblink_close</primary>
   </indexterm>
@@ -1057,7 +1057,7 @@ SELECT dblink_close('foo');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-GET-CONNECTIONS">
+ <refentry id="contrib-dblink-get-connections">
   <indexterm>
    <primary>dblink_get_connections</primary>
   </indexterm>
@@ -1102,7 +1102,7 @@ SELECT dblink_get_connections();
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-ERROR-MESSAGE">
+ <refentry id="contrib-dblink-error-message">
   <indexterm>
    <primary>dblink_error_message</primary>
   </indexterm>
@@ -1165,7 +1165,7 @@ SELECT dblink_error_message('dtest1');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-SEND-QUERY">
+ <refentry id="contrib-dblink-send-query">
   <indexterm>
    <primary>dblink_send_query</primary>
   </indexterm>
@@ -1247,7 +1247,7 @@ SELECT dblink_send_query('dtest1', 'SELECT * FROM foo WHERE f1 &lt; 3');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-IS-BUSY">
+ <refentry id="contrib-dblink-is-busy">
   <indexterm>
    <primary>dblink_is_busy</primary>
   </indexterm>
@@ -1310,7 +1310,7 @@ SELECT dblink_is_busy('dtest1');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-GET-NOTIFY">
+ <refentry id="contrib-dblink-get-notify">
   <indexterm>
    <primary>dblink_get_notify</primary>
   </indexterm>
@@ -1392,7 +1392,7 @@ SELECT * FROM dblink_get_notify();
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-GET-RESULT">
+ <refentry id="contrib-dblink-get-result">
   <indexterm>
    <primary>dblink_get_result</primary>
   </indexterm>
@@ -1556,7 +1556,7 @@ contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-CANCEL-QUERY">
+ <refentry id="contrib-dblink-cancel-query">
   <indexterm>
    <primary>dblink_cancel_query</primary>
   </indexterm>
@@ -1624,7 +1624,7 @@ SELECT dblink_cancel_query('dtest1');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-GET-PKEY">
+ <refentry id="contrib-dblink-get-pkey">
   <indexterm>
    <primary>dblink_get_pkey</primary>
   </indexterm>
@@ -1716,7 +1716,7 @@ SELECT * FROM dblink_get_pkey('foobar');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-BUILD-SQL-INSERT">
+ <refentry id="contrib-dblink-build-sql-insert">
   <indexterm>
    <primary>dblink_build_sql_insert</primary>
   </indexterm>
@@ -1851,7 +1851,7 @@ SELECT dblink_build_sql_insert('foo', '1 2', 2, '{"1", "a"}', '{"1", "b''a"}');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-BUILD-SQL-DELETE">
+ <refentry id="contrib-dblink-build-sql-delete">
   <indexterm>
    <primary>dblink_build_sql_delete</primary>
   </indexterm>
@@ -1969,7 +1969,7 @@ SELECT dblink_build_sql_delete('"MyFoo"', '1 2', 2, '{"1", "b"}');
   </refsect1>
  </refentry>
 
- <refentry id="CONTRIB-DBLINK-BUILD-SQL-UPDATE">
+ <refentry id="contrib-dblink-build-sql-update">
   <indexterm>
    <primary>dblink_build_sql_update</primary>
   </indexterm>
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 817db92af2d..03cbaa60abd 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -908,7 +908,7 @@ CREATE TABLE circles (
    </para>
 
    <para>
-    See also <link linkend="SQL-CREATETABLE-EXCLUDE"><command>CREATE
+    See also <link linkend="sql-createtable-exclude"><command>CREATE
     TABLE ... CONSTRAINT ... EXCLUDE</command></link> for details.
    </para>
 
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index 0f9ff3a8eb8..bc3d080774d 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -2270,7 +2270,7 @@ int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst);
    <para>
     The following functions can be used to work with the date type:
     <variablelist>
-     <varlistentry id="PGTYPESdatefromtimestamp">
+     <varlistentry id="pgtypesdatefromtimestamp">
       <term><function>PGTYPESdate_from_timestamp</function></term>
       <listitem>
        <para>
@@ -2284,7 +2284,7 @@ date PGTYPESdate_from_timestamp(timestamp dt);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatefromasc">
+     <varlistentry id="pgtypesdatefromasc">
       <term><function>PGTYPESdate_from_asc</function></term>
       <listitem>
        <para>
@@ -2389,7 +2389,7 @@ date PGTYPESdate_from_asc(char *str, char **endptr);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatetoasc">
+     <varlistentry id="pgtypesdatetoasc">
       <term><function>PGTYPESdate_to_asc</function></term>
       <listitem>
        <para>
@@ -2404,7 +2404,7 @@ char *PGTYPESdate_to_asc(date dDate);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatejulmdy">
+     <varlistentry id="pgtypesdatejulmdy">
       <term><function>PGTYPESdate_julmdy</function></term>
       <listitem>
        <para>
@@ -2423,7 +2423,7 @@ void PGTYPESdate_julmdy(date d, int *mdy);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatemdyjul">
+     <varlistentry id="pgtypesdatemdyjul">
       <term><function>PGTYPESdate_mdyjul</function></term>
       <listitem>
        <para>
@@ -2439,7 +2439,7 @@ void PGTYPESdate_mdyjul(int *mdy, date *jdate);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatedayofweek">
+     <varlistentry id="pgtypesdatedayofweek">
       <term><function>PGTYPESdate_dayofweek</function></term>
       <listitem>
        <para>
@@ -2491,7 +2491,7 @@ int PGTYPESdate_dayofweek(date d);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatetoday">
+     <varlistentry id="pgtypesdatetoday">
       <term><function>PGTYPESdate_today</function></term>
       <listitem>
        <para>
@@ -2505,7 +2505,7 @@ void PGTYPESdate_today(date *d);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatefmtasc">
+     <varlistentry id="pgtypesdatefmtasc">
       <term><function>PGTYPESdate_fmt_asc</function></term>
       <listitem>
        <para>
@@ -2626,7 +2626,7 @@ int PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESdatedefmtasc">
+     <varlistentry id="pgtypesdatedefmtasc">
       <term><function>PGTYPESdate_defmt_asc</function></term>
       <listitem>
        <para>
@@ -2747,7 +2747,7 @@ int PGTYPESdate_defmt_asc(date *d, char *fmt, char *str);
    <para>
     The following functions can be used to work with the timestamp type:
     <variablelist>
-     <varlistentry id="PGTYPEStimestampfromasc">
+     <varlistentry id="pgtypestimestampfromasc">
       <term><function>PGTYPEStimestamp_from_asc</function></term>
       <listitem>
        <para>
@@ -2766,7 +2766,7 @@ timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr);
        <para>
         The function returns the parsed timestamp on success. On error,
         <literal>PGTYPESInvalidTimestamp</literal> is returned and <varname>errno</varname> is
-        set to <literal>PGTYPES_TS_BAD_TIMESTAMP</literal>. See <xref linkend="PGTYPESInvalidTimestamp"> for important notes on this value.
+        set to <literal>PGTYPES_TS_BAD_TIMESTAMP</literal>. See <xref linkend="pgtypesinvalidtimestamp"> for important notes on this value.
        </para>
        <para>
         In general, the input string can contain any combination of an allowed
@@ -2811,7 +2811,7 @@ timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestamptoasc">
+     <varlistentry id="pgtypestimestamptoasc">
       <term><function>PGTYPEStimestamp_to_asc</function></term>
       <listitem>
        <para>
@@ -2826,7 +2826,7 @@ char *PGTYPEStimestamp_to_asc(timestamp tstamp);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampcurrent">
+     <varlistentry id="pgtypestimestampcurrent">
       <term><function>PGTYPEStimestamp_current</function></term>
       <listitem>
        <para>
@@ -2840,7 +2840,7 @@ void PGTYPEStimestamp_current(timestamp *ts);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampfmtasc">
+     <varlistentry id="pgtypestimestampfmtasc">
       <term><function>PGTYPEStimestamp_fmt_asc</function></term>
       <listitem>
        <para>
@@ -3175,7 +3175,7 @@ int PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmt
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampsub">
+     <varlistentry id="pgtypestimestampsub">
       <term><function>PGTYPEStimestamp_sub</function></term>
       <listitem>
        <para>
@@ -3196,7 +3196,7 @@ int PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampdefmtasc">
+     <varlistentry id="pgtypestimestampdefmtasc">
       <term><function>PGTYPEStimestamp_defmt_asc</function></term>
       <listitem>
        <para>
@@ -3217,13 +3217,13 @@ int PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d);
        </para>
        <para>
         This is the reverse function to <xref
-        linkend="PGTYPEStimestampfmtasc">.  See the documentation there in
+        linkend="pgtypestimestampfmtasc">.  See the documentation there in
         order to find out about the possible formatting mask entries.
        </para>
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampaddinterval">
+     <varlistentry id="pgtypestimestampaddinterval">
       <term><function>PGTYPEStimestamp_add_interval</function></term>
       <listitem>
        <para>
@@ -3243,7 +3243,7 @@ int PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tou
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPEStimestampsubinterval">
+     <varlistentry id="pgtypestimestampsubinterval">
       <term><function>PGTYPEStimestamp_sub_interval</function></term>
       <listitem>
        <para>
@@ -3277,7 +3277,7 @@ int PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tou
     The following functions can be used to work with the interval type:
     <variablelist>
 
-     <varlistentry id="PGTYPESintervalnew">
+     <varlistentry id="pgtypesintervalnew">
       <term><function>PGTYPESinterval_new</function></term>
       <listitem>
        <para>
@@ -3289,7 +3289,7 @@ interval *PGTYPESinterval_new(void);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESintervalfree">
+     <varlistentry id="pgtypesintervalfree">
       <term><function>PGTYPESinterval_free</function></term>
       <listitem>
        <para>
@@ -3301,7 +3301,7 @@ void PGTYPESinterval_new(interval *intvl);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESintervalfromasc">
+     <varlistentry id="pgtypesintervalfromasc">
       <term><function>PGTYPESinterval_from_asc</function></term>
       <listitem>
        <para>
@@ -3319,7 +3319,7 @@ interval *PGTYPESinterval_from_asc(char *str, char **endptr);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESintervaltoasc">
+     <varlistentry id="pgtypesintervaltoasc">
       <term><function>PGTYPESinterval_to_asc</function></term>
       <listitem>
        <para>
@@ -3334,7 +3334,7 @@ char *PGTYPESinterval_to_asc(interval *span);
       </listitem>
      </varlistentry>
 
-     <varlistentry id="PGTYPESintervalcopy">
+     <varlistentry id="pgtypesintervalcopy">
       <term><function>PGTYPESinterval_copy</function></term>
       <listitem>
        <para>
@@ -3543,7 +3543,7 @@ void PGTYPESdecimal_free(decimal *var);
     <title>Special Constants of pgtypeslib</title>
    <para>
     <variablelist>
-     <varlistentry id="PGTYPESInvalidTimestamp">
+     <varlistentry id="pgtypesinvalidtimestamp">
       <term><literal>PGTYPESInvalidTimestamp</literal></term>
       <listitem>
        <para>
@@ -5868,7 +5868,7 @@ ECPG = ecpg
   <para>
    For more details about the <function>ECPGget_PGconn()</function>, see
    <xref linkend="ecpg-library">.  For information about the large
-   object function interface, see <xref linkend="largeObjects">.
+   object function interface, see <xref linkend="largeobjects">.
   </para>
 
   <para>
@@ -8653,7 +8653,7 @@ void rtoday(date *d);
         that it sets to the current date.
        </para>
        <para>
-        Internally this function uses the <xref linkend="PGTYPESdatetoday">
+        Internally this function uses the <xref linkend="pgtypesdatetoday">
         function.
        </para>
       </listitem>
@@ -8678,7 +8678,7 @@ int rjulmdy(date d, short mdy[3]);
         The function always returns 0 at the moment.
        </para>
        <para>
-        Internally the function uses the <xref linkend="PGTYPESdatejulmdy">
+        Internally the function uses the <xref linkend="pgtypesdatejulmdy">
         function.
        </para>
       </listitem>
@@ -8748,7 +8748,7 @@ int rdefmtdate(date *d, char *fmt, char *str);
        </para>
        <para>
         Internally this function is implemented to use the <xref
-        linkend="PGTYPESdatedefmtasc"> function. See the reference there for a
+        linkend="pgtypesdatedefmtasc"> function. See the reference there for a
         table of example input.
        </para>
       </listitem>
@@ -8771,7 +8771,7 @@ int rfmtdate(date d, char *fmt, char *str);
         On success, 0 is returned and a negative value if an error occurred.
        </para>
        <para>
-        Internally this function uses the <xref linkend="PGTYPESdatefmtasc">
+        Internally this function uses the <xref linkend="pgtypesdatefmtasc">
         function, see the reference there for examples.
        </para>
       </listitem>
@@ -8795,7 +8795,7 @@ int rmdyjul(short mdy[3], date *d);
        </para>
        <para>
         Internally the function is implemented to use the function <xref
-        linkend="PGTYPESdatemdyjul">.
+        linkend="pgtypesdatemdyjul">.
        </para>
       </listitem>
      </varlistentry>
@@ -8851,7 +8851,7 @@ int rdayofweek(date d);
        </para>
        <para>
         Internally the function is implemented to use the function <xref
-        linkend="PGTYPESdatedayofweek">.
+        linkend="pgtypesdatedayofweek">.
        </para>
       </listitem>
      </varlistentry>
@@ -8889,7 +8889,7 @@ int dtcvasc(char *str, timestamp *ts);
        </para>
        <para>
         Internally this function uses the <xref
-        linkend="PGTYPEStimestampfromasc"> function. See the reference there
+        linkend="pgtypestimestampfromasc"> function. See the reference there
         for a table with example inputs.
        </para>
       </listitem>
@@ -8911,7 +8911,7 @@ dtcvfmtasc(char *inbuf, char *fmtstr, timestamp *dtvalue)
        </para>
        <para>
         This function is implemented by means of the <xref
-        linkend="PGTYPEStimestampdefmtasc"> function. See the documentation
+        linkend="pgtypestimestampdefmtasc"> function. See the documentation
         there for a list of format specifiers that can be used.
        </para>
        <para>
@@ -8983,7 +8983,7 @@ int dttofmtasc(timestamp *ts, char *output, int str_len, char *fmtstr);
        </para>
        <para>
         Internally, this function uses the <xref
-        linkend="PGTYPEStimestampfmtasc"> function. See the reference there for
+        linkend="pgtypestimestampfmtasc"> function. See the reference there for
         information on what format mask specifiers can be used.
        </para>
       </listitem>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index c672988cc51..e571292bf4b 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -17866,7 +17866,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
     logging and checkpoint processing. This information is cluster-wide,
     and not specific to any one database. They provide most of the same
     information, from the same source, as
-    <xref linkend="APP-PGCONTROLDATA">, although in a form better suited
+    <xref linkend="app-pgcontroldata">, although in a form better suited
     to <acronym>SQL</acronym> functions.
    </para>
 
@@ -20376,7 +20376,7 @@ FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
     </para>
     <para>
        For more information about creating triggers, see
-        <xref linkend="SQL-CREATETRIGGER">.
+        <xref linkend="sql-createtrigger">.
     </para>
   </sect1>
 
diff --git a/doc/src/sgml/geqo.sgml b/doc/src/sgml/geqo.sgml
index 99ee3ebca01..0f91272c54e 100644
--- a/doc/src/sgml/geqo.sgml
+++ b/doc/src/sgml/geqo.sgml
@@ -320,13 +320,13 @@
 
     <listitem>
      <para>
-      <xref linkend="ELMA04">
+      <xref linkend="elma04">
      </para>
     </listitem>
 
     <listitem>
      <para>
-      <xref linkend="FONG">
+      <xref linkend="fong">
      </para>
     </listitem>
    </itemizedlist>
diff --git a/doc/src/sgml/gin.sgml b/doc/src/sgml/gin.sgml
index 873627a210b..d63d8af4405 100644
--- a/doc/src/sgml/gin.sgml
+++ b/doc/src/sgml/gin.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/gin.sgml -->
 
-<chapter id="GIN">
+<chapter id="gin">
 <title>GIN Indexes</title>
 
    <indexterm>
diff --git a/doc/src/sgml/gist.sgml b/doc/src/sgml/gist.sgml
index 4e4470d439b..f2f9ca0853c 100644
--- a/doc/src/sgml/gist.sgml
+++ b/doc/src/sgml/gist.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/gist.sgml -->
 
-<chapter id="GiST">
+<chapter id="gist">
 <title>GiST Indexes</title>
 
    <indexterm>
diff --git a/doc/src/sgml/history.sgml b/doc/src/sgml/history.sgml
index d1535469f98..b59e65bb209 100644
--- a/doc/src/sgml/history.sgml
+++ b/doc/src/sgml/history.sgml
@@ -31,12 +31,12 @@
    Office (<acronym>ARO</acronym>), the National Science Foundation
    (<acronym>NSF</acronym>), and ESL, Inc.  The implementation of
    <productname>POSTGRES</productname> began in 1986.  The initial
-   concepts for the system were presented in <xref linkend="STON86">,
+   concepts for the system were presented in <xref linkend="ston86">,
    and the definition of the initial data model appeared in <xref
-   linkend="ROWE87">.  The design of the rule system at that time was
-   described in <xref linkend="STON87a">.  The rationale and
+   linkend="rowe87">.  The design of the rule system at that time was
+   described in <xref linkend="ston87a">.  The rationale and
    architecture of the storage manager were detailed in <xref
-   linkend="STON87b">.
+   linkend="ston87b">.
   </para>
 
   <para>
@@ -44,10 +44,10 @@
    releases since then.  The first <quote>demoware</quote> system
    became operational in 1987 and was shown at the 1988
    <acronym>ACM-SIGMOD</acronym> Conference.  Version 1, described in
-   <xref linkend="STON90a">, was released to a few external users in
+   <xref linkend="ston90a">, was released to a few external users in
    June 1989.  In response to a critique of the first rule system
-   (<xref linkend="STON89">), the rule system was redesigned (<xref
-   linkend="STON90b">), and Version 2 was released in June 1990 with
+   (<xref linkend="ston89">), the rule system was redesigned (<xref
+   linkend="ston90b">), and Version 2 was released in June 1990 with
    the new rule system.  Version 3 appeared in 1991 and added support
    for multiple storage managers, an improved query executor, and a
    rewritten rule system.  For the most part, subsequent releases
diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml
index 4cdd387b7be..248ed7e8eb0 100644
--- a/doc/src/sgml/indices.sgml
+++ b/doc/src/sgml/indices.sgml
@@ -98,8 +98,8 @@ CREATE INDEX test1_id_index ON test1 (id);
    In production environments this is often unacceptable.
    It is possible to allow writes to occur in parallel with index
    creation, but there are several caveats to be aware of &mdash;
-   for more information see <xref linkend="SQL-CREATEINDEX-CONCURRENTLY"
-   endterm="SQL-CREATEINDEX-CONCURRENTLY-title">.
+   for more information see <xref linkend="sql-createindex-concurrently"
+   endterm="sql-createindex-concurrently-title">.
   </para>
 
   <para>
@@ -232,7 +232,7 @@ CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable>
    documented in <xref linkend="gist-builtin-opclasses-table">.
    Many other GiST operator
    classes are available in the <literal>contrib</literal> collection or as separate
-   projects.  For more information see <xref linkend="GiST">.
+   projects.  For more information see <xref linkend="gist">.
   </para>
 
   <para>
@@ -278,7 +278,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
    these operators.)
    The SP-GiST operator classes included in the standard distribution are
    documented in <xref linkend="spgist-builtin-opclasses-table">.
-   For more information see <xref linkend="SPGiST">.
+   For more information see <xref linkend="spgist">.
   </para>
 
   <para>
@@ -319,7 +319,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
    documented in <xref linkend="gin-builtin-opclasses-table">.
    Many other GIN operator
    classes are available in the <literal>contrib</literal> collection or as separate
-   projects.  For more information see <xref linkend="GIN">.
+   projects.  For more information see <xref linkend="gin">.
   </para>
 
   <para>
@@ -352,7 +352,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
    The BRIN operator classes included in the standard distribution are
    documented in <xref linkend="brin-builtin-opclasses-table">.
-   For more information see <xref linkend="BRIN">.
+   For more information see <xref linkend="brin">.
   </para>
  </sect1>
 
@@ -962,8 +962,8 @@ CREATE UNIQUE INDEX tests_success_constraint ON tests (subject, target)
 
   <para>
    More information about partial indexes can be found in <xref
-   linkend="STON89b">, <xref linkend="OLSON93">, and <xref
-   linkend="SESHADRI95">.
+   linkend="ston89b">, <xref linkend="olson93">, and <xref
+   linkend="seshadri95">.
   </para>
  </sect1>
 
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index a7e26533716..9f468b7fdc9 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -2447,7 +2447,7 @@ PGresult *PQprepare(PGconn *conn,
         <function>PQprepare</function> creates a prepared statement for later
         execution with <function>PQexecPrepared</function>.  This feature allows
         commands to be executed repeatedly without being parsed and
-        planned each time;  see <xref linkend="SQL-PREPARE"> for details.
+        planned each time;  see <xref linkend="sql-prepare"> for details.
         <function>PQprepare</function> is supported only in protocol 3.0 and later
         connections; it will fail when using protocol 2.0.
        </para>
diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml
index 2e930ac240f..c743b5c0baa 100644
--- a/doc/src/sgml/lobj.sgml
+++ b/doc/src/sgml/lobj.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/lobj.sgml -->
 
- <chapter id="largeObjects">
+ <chapter id="largeobjects">
   <title>Large Objects</title>
 
   <indexterm zone="largeobjects"><primary>large object</primary></indexterm>
diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml
index fa0bb56b7bf..676ab1f5ad7 100644
--- a/doc/src/sgml/logical-replication.sgml
+++ b/doc/src/sgml/logical-replication.sgml
@@ -126,7 +126,7 @@
    fallback if no other solution is possible.  If a replica identity other
    than <quote>full</quote> is set on the publisher side, a replica identity
    comprising the same or fewer columns must also be set on the subscriber
-   side.  See <xref linkend="SQL-CREATETABLE-REPLICA-IDENTITY"> for details on
+   side.  See <xref linkend="sql-createtable-replica-identity"> for details on
    how to set the replica identity.  If a table without a replica identity is
    added to a publication that replicates <command>UPDATE</command>
    or <command>DELETE</command> operations then
diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml
index c02f6e97652..3b268c3f3c8 100644
--- a/doc/src/sgml/logicaldecoding.sgml
+++ b/doc/src/sgml/logicaldecoding.sgml
@@ -24,7 +24,7 @@
    by <command>INSERT</command> and the new row version created
    by <command>UPDATE</command>.  Availability of old row versions for
    <command>UPDATE</command> and <command>DELETE</command> depends on
-   the configured replica identity (see <xref linkend="SQL-CREATETABLE-REPLICA-IDENTITY">).
+   the configured replica identity (see <xref linkend="sql-createtable-replica-identity">).
   </para>
 
   <para>
@@ -576,8 +576,8 @@ typedef void (*LogicalDecodeChangeCB) (struct LogicalDecodingContext *ctx,
      <note>
       <para>
        Only changes in user defined tables that are not unlogged
-       (see <xref linkend="SQL-CREATETABLE-UNLOGGED">) and not temporary
-       (see <xref linkend="SQL-CREATETABLE-TEMPORARY">) can be extracted using
+       (see <xref linkend="sql-createtable-unlogged">) and not temporary
+       (see <xref linkend="sql-createtable-temporary">) can be extracted using
        logical decoding.
       </para>
      </note>
diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml
index 75cb39359fa..a0ca2851e57 100644
--- a/doc/src/sgml/mvcc.sgml
+++ b/doc/src/sgml/mvcc.sgml
@@ -929,7 +929,7 @@ ERROR:  could not serialize access due to read/write dependencies among transact
          <command>CREATE STATISTICS</command> and
          <command>ALTER TABLE VALIDATE</command> and other
          <command>ALTER TABLE</command> variants (for full details see
-         <xref linkend="SQL-ALTERTABLE">).
+         <xref linkend="sql-altertable">).
         </para>
        </listitem>
       </varlistentry>
@@ -972,7 +972,7 @@ ERROR:  could not serialize access due to read/write dependencies among transact
         <para>
          Acquired by <command>CREATE COLLATION</command>,
          <command>CREATE TRIGGER</command>, and many forms of
-         <command>ALTER TABLE</command> (see <xref linkend="SQL-ALTERTABLE">).
+         <command>ALTER TABLE</command> (see <xref linkend="sql-altertable">).
         </para>
        </listitem>
       </varlistentry>
diff --git a/doc/src/sgml/passwordcheck.sgml b/doc/src/sgml/passwordcheck.sgml
index 6e6e4ef4356..d034f8887f3 100644
--- a/doc/src/sgml/passwordcheck.sgml
+++ b/doc/src/sgml/passwordcheck.sgml
@@ -10,8 +10,8 @@
  <para>
   The <filename>passwordcheck</filename> module checks users' passwords
   whenever they are set with
-  <xref linkend="SQL-CREATEROLE"> or
-  <xref linkend="SQL-ALTERROLE">.
+  <xref linkend="sql-createrole"> or
+  <xref linkend="sql-alterrole">.
   If a password is considered too weak, it will be rejected and
   the command will terminate with an error.
  </para>
diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml
index 6a5182d85b8..fed5c956a20 100644
--- a/doc/src/sgml/perform.sgml
+++ b/doc/src/sgml/perform.sgml
@@ -1848,7 +1848,7 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
 
      <listitem>
       <para>
-       Create <link linkend="SQL-CREATETABLE-UNLOGGED">unlogged
+       Create <link linkend="sql-createtable-unlogged">unlogged
        tables</link> to avoid <acronym>WAL</acronym> writes, though it
        makes the tables non-crash-safe.
       </para>
diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml
index c2c1aaa208e..52cc37a1d61 100644
--- a/doc/src/sgml/queries.sgml
+++ b/doc/src/sgml/queries.sgml
@@ -795,7 +795,7 @@ SELECT *
       AS t1(proname name, prosrc text)
     WHERE proname LIKE 'bytea%';
 </programlisting>
-     The <xref linkend="CONTRIB-DBLINK-FUNCTION"> function
+     The <xref linkend="contrib-dblink-function"> function
      (part of the <xref linkend="dblink"> module) executes
      a remote query.  It is declared to return
      <type>record</type> since it might be used for any kind of query.
diff --git a/doc/src/sgml/query.sgml b/doc/src/sgml/query.sgml
index fc60febcbd4..b139c345778 100644
--- a/doc/src/sgml/query.sgml
+++ b/doc/src/sgml/query.sgml
@@ -12,7 +12,7 @@
     tutorial is only intended to give you an introduction and is in no
     way a complete tutorial on <acronym>SQL</acronym>.  Numerous books
     have been written on <acronym>SQL</acronym>, including <xref
-    linkend="MELT93"> and <xref linkend="DATE97">.
+    linkend="melt93"> and <xref linkend="date97">.
     You should be aware that some <productname>PostgreSQL</productname>
     language features are extensions to the standard.
    </para>
diff --git a/doc/src/sgml/rangetypes.sgml b/doc/src/sgml/rangetypes.sgml
index b585fd3d2ac..ef2bff9cd93 100644
--- a/doc/src/sgml/rangetypes.sgml
+++ b/doc/src/sgml/rangetypes.sgml
@@ -65,7 +65,7 @@
     </listitem>
   </itemizedlist>
   In addition, you can define your own range types;
-  see <xref linkend="SQL-CREATETYPE"> for more information.
+  see <xref linkend="sql-createtype"> for more information.
  </para>
  </sect2>
 
@@ -406,7 +406,7 @@ SELECT '[11:10, 23:00]'::timerange;
 </programlisting>
 
   <para>
-   See <xref linkend="SQL-CREATETYPE"> for more information about creating
+   See <xref linkend="sql-createtype"> for more information about creating
    range types.
   </para>
  </sect2>
@@ -462,7 +462,7 @@ CREATE INDEX reservation_idx ON reservation USING GIST (during);
    While <literal>UNIQUE</literal> is a natural constraint for scalar
    values, it is usually unsuitable for range types. Instead, an
    exclusion constraint is often more appropriate
-   (see <link linkend="SQL-CREATETABLE-EXCLUDE">CREATE TABLE
+   (see <link linkend="sql-createtable-exclude">CREATE TABLE
    ... CONSTRAINT ... EXCLUDE</link>). Exclusion constraints allow the
    specification of constraints such as <quote>non-overlapping</quote> on a
    range type. For example:
diff --git a/doc/src/sgml/ref/abort.sgml b/doc/src/sgml/ref/abort.sgml
index 285d0d4ac65..d3415957856 100644
--- a/doc/src/sgml/ref/abort.sgml
+++ b/doc/src/sgml/ref/abort.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/abort.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ABORT">
+<refentry id="sql-abort">
  <indexterm zone="sql-abort">
   <primary>ABORT</primary>
  </indexterm>
@@ -33,7 +33,7 @@ ABORT [ WORK | TRANSACTION ]
    all the updates made by the transaction to be discarded.
    This command is identical
    in behavior to the standard <acronym>SQL</acronym> command
-   <xref linkend="SQL-ROLLBACK">,
+   <xref linkend="sql-rollback">,
    and is present only for historical reasons.
   </para>
  </refsect1>
@@ -58,7 +58,7 @@ ABORT [ WORK | TRANSACTION ]
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-COMMIT"> to
+   Use <xref linkend="sql-commit"> to
    successfully terminate a transaction.
   </para>
 
diff --git a/doc/src/sgml/ref/alter_aggregate.sgml b/doc/src/sgml/ref/alter_aggregate.sgml
index 43f0a1609b9..e00e726ad85 100644
--- a/doc/src/sgml/ref/alter_aggregate.sgml
+++ b/doc/src/sgml/ref/alter_aggregate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_aggregate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERAGGREGATE">
+<refentry id="sql-alteraggregate">
  <indexterm zone="sql-alteraggregate">
   <primary>ALTER AGGREGATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_collation.sgml b/doc/src/sgml/ref/alter_collation.sgml
index 9d77ee5c2c3..c7ad7437e87 100644
--- a/doc/src/sgml/ref/alter_collation.sgml
+++ b/doc/src/sgml/ref/alter_collation.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_collation.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERCOLLATION">
+<refentry id="sql-altercollation">
  <indexterm zone="sql-altercollation">
   <primary>ALTER COLLATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_conversion.sgml b/doc/src/sgml/ref/alter_conversion.sgml
index 83fcbbd5a5d..08ed5e28fbf 100644
--- a/doc/src/sgml/ref/alter_conversion.sgml
+++ b/doc/src/sgml/ref/alter_conversion.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_conversion.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERCONVERSION">
+<refentry id="sql-alterconversion">
  <indexterm zone="sql-alterconversion">
   <primary>ALTER CONVERSION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_database.sgml b/doc/src/sgml/ref/alter_database.sgml
index 35e4123cadd..1e09b5df1d9 100644
--- a/doc/src/sgml/ref/alter_database.sgml
+++ b/doc/src/sgml/ref/alter_database.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_database.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERDATABASE">
+<refentry id="sql-alterdatabase">
  <indexterm zone="sql-alterdatabase">
   <primary>ALTER DATABASE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_default_privileges.sgml b/doc/src/sgml/ref/alter_default_privileges.sgml
index 6c34f2446a7..bc7401f845a 100644
--- a/doc/src/sgml/ref/alter_default_privileges.sgml
+++ b/doc/src/sgml/ref/alter_default_privileges.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_default_privileges.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERDEFAULTPRIVILEGES">
+<refentry id="sql-alterdefaultprivileges">
  <indexterm zone="sql-alterdefaultprivileges">
   <primary>ALTER DEFAULT PRIVILEGES</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_domain.sgml b/doc/src/sgml/ref/alter_domain.sgml
index 96a7db95ecf..26e95aefcfd 100644
--- a/doc/src/sgml/ref/alter_domain.sgml
+++ b/doc/src/sgml/ref/alter_domain.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_domain.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERDOMAIN">
+<refentry id="sql-alterdomain">
  <indexterm zone="sql-alterdomain">
   <primary>ALTER DOMAIN</primary>
  </indexterm>
@@ -80,7 +80,7 @@ ALTER DOMAIN <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form adds a new constraint to a domain using the same syntax as
-      <xref linkend="SQL-CREATEDOMAIN">.
+      <xref linkend="sql-createdomain">.
       When a new constraint is added to a domain, all columns using that
       domain will be checked against the newly added constraint.  These
       checks can be suppressed by adding the new constraint using the
@@ -325,7 +325,7 @@ ALTER DOMAIN zipcode SET SCHEMA customers;
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-ALTERDOMAIN-compatibility">
+ <refsect1 id="sql-alterdomain-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -338,7 +338,7 @@ ALTER DOMAIN zipcode SET SCHEMA customers;
   </para>
  </refsect1>
 
- <refsect1 id="SQL-ALTERDOMAIN-see-also">
+ <refsect1 id="sql-alterdomain-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/alter_event_trigger.sgml b/doc/src/sgml/ref/alter_event_trigger.sgml
index 38b971fb08a..b913ac9a5bd 100644
--- a/doc/src/sgml/ref/alter_event_trigger.sgml
+++ b/doc/src/sgml/ref/alter_event_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_event_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTEREVENTTRIGGER">
+<refentry id="sql-altereventtrigger">
  <indexterm zone="sql-altereventtrigger">
   <primary>ALTER EVENT TRIGGER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_extension.sgml b/doc/src/sgml/ref/alter_extension.sgml
index c6c831fa30a..c2b0669c381 100644
--- a/doc/src/sgml/ref/alter_extension.sgml
+++ b/doc/src/sgml/ref/alter_extension.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_extension.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTEREXTENSION">
+<refentry id="sql-alterextension">
  <indexterm zone="sql-alterextension">
   <primary>ALTER EXTENSION</primary>
  </indexterm>
@@ -319,7 +319,7 @@ ALTER EXTENSION hstore ADD FUNCTION populate_record(anyelement, hstore);
   </para>
  </refsect1>
 
- <refsect1 id="SQL-ALTEREXTENSION-see-also">
+ <refsect1 id="sql-alterextension-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml b/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
index 1c0a26de6ba..21bc83e512c 100644
--- a/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERFOREIGNDATAWRAPPER">
+<refentry id="sql-alterforeigndatawrapper">
  <indexterm zone="sql-alterforeigndatawrapper">
   <primary>ALTER FOREIGN DATA WRAPPER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_foreign_table.sgml b/doc/src/sgml/ref/alter_foreign_table.sgml
index 44d981a5bda..df3d6d0696d 100644
--- a/doc/src/sgml/ref/alter_foreign_table.sgml
+++ b/doc/src/sgml/ref/alter_foreign_table.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/rel/alter_foreign_table.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERFOREIGNTABLE">
+<refentry id="sql-alterforeigntable">
  <indexterm zone="sql-alterforeigntable">
   <primary>ALTER FOREIGN TABLE</primary>
  </indexterm>
@@ -72,7 +72,7 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
     <listitem>
      <para>
       This form adds a new column to the foreign table, using the same syntax as
-      <xref linkend="SQL-CREATEFOREIGNTABLE">.
+      <xref linkend="sql-createforeigntable">.
       Unlike the case when adding a column to a regular table, nothing happens
       to the underlying storage: this action simply declares that
       some new column is now accessible through the foreign table.
@@ -173,7 +173,7 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
     <listitem>
      <para>
       This form adds a new constraint to a foreign table, using the same
-      syntax as <xref linkend="SQL-CREATEFOREIGNTABLE">.
+      syntax as <xref linkend="sql-createforeigntable">.
       Currently only <literal>CHECK</literal> constraints are supported.
      </para>
 
@@ -182,7 +182,7 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
       done to verify the constraint is correct; rather, this action simply
       declares that some new condition should be assumed to hold for all rows
       in the foreign table.  (See the discussion
-      in <xref linkend="SQL-CREATEFOREIGNTABLE">.)
+      in <xref linkend="sql-createforeigntable">.)
       If the constraint is marked <literal>NOT VALID</literal>, then it isn't
       assumed to hold, but is only recorded for possible future use.
      </para>
diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml
index cdecf631b1e..fd35e98a886 100644
--- a/doc/src/sgml/ref/alter_function.sgml
+++ b/doc/src/sgml/ref/alter_function.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_function.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERFUNCTION">
+<refentry id="sql-alterfunction">
  <indexterm zone="sql-alterfunction">
   <primary>ALTER FUNCTION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_group.sgml b/doc/src/sgml/ref/alter_group.sgml
index a9001458731..172a62a6f7d 100644
--- a/doc/src/sgml/ref/alter_group.sgml
+++ b/doc/src/sgml/ref/alter_group.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_group.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERGROUP">
+<refentry id="sql-altergroup">
  <indexterm zone="sql-altergroup">
   <primary>ALTER GROUP</primary>
  </indexterm>
@@ -50,8 +50,8 @@ ALTER GROUP <replaceable class="parameter">group_name</replaceable> RENAME TO <r
    <quote>group</quote> for this purpose.)  These variants are effectively
    equivalent to granting or revoking membership in the role named as the
    <quote>group</quote>; so the preferred way to do this is to use
-   <xref linkend="SQL-GRANT"> or
-   <xref linkend="SQL-REVOKE">.
+   <xref linkend="sql-grant"> or
+   <xref linkend="sql-revoke">.
   </para>
 
   <para>
diff --git a/doc/src/sgml/ref/alter_index.sgml b/doc/src/sgml/ref/alter_index.sgml
index 30e399e62c8..5d0b792e505 100644
--- a/doc/src/sgml/ref/alter_index.sgml
+++ b/doc/src/sgml/ref/alter_index.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_index.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERINDEX">
+<refentry id="sql-alterindex">
  <indexterm zone="sql-alterindex">
   <primary>ALTER INDEX</primary>
  </indexterm>
@@ -70,7 +70,7 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="parameter">name</replaceable>
       this command, use <command>ALTER DATABASE</command> or explicit
       <command>ALTER INDEX</command> invocations instead if desired.
       See also
-      <xref linkend="SQL-CREATETABLESPACE">.
+      <xref linkend="sql-createtablespace">.
      </para>
     </listitem>
    </varlistentry>
@@ -91,11 +91,11 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="parameter">name</replaceable>
      <para>
       This form changes one or more index-method-specific storage parameters
       for the index.  See
-      <xref linkend="SQL-CREATEINDEX">
+      <xref linkend="sql-createindex">
       for details on the available parameters.  Note that the index contents
       will not be modified immediately by this command; depending on the
       parameter you might need to rebuild the index with
-      <xref linkend="SQL-REINDEX">
+      <xref linkend="sql-reindex">
       to get the desired effects.
      </para>
     </listitem>
@@ -225,7 +225,7 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="parameter">name</replaceable>
 
    <para>
     These operations are also possible using
-    <xref linkend="SQL-ALTERTABLE">.
+    <xref linkend="sql-altertable">.
     <command>ALTER INDEX</command> is in fact just an alias for the forms
     of <command>ALTER TABLE</command> that apply to indexes.
    </para>
diff --git a/doc/src/sgml/ref/alter_language.sgml b/doc/src/sgml/ref/alter_language.sgml
index 63d9ecd924d..389824e3d21 100644
--- a/doc/src/sgml/ref/alter_language.sgml
+++ b/doc/src/sgml/ref/alter_language.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_language.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERLANGUAGE">
+<refentry id="sql-alterlanguage">
  <indexterm zone="sql-alterlanguage">
   <primary>ALTER LANGUAGE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_large_object.sgml b/doc/src/sgml/ref/alter_large_object.sgml
index 5e680f7720c..0fbb8d5b624 100644
--- a/doc/src/sgml/ref/alter_large_object.sgml
+++ b/doc/src/sgml/ref/alter_large_object.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_large_object.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERLARGEOBJECT">
+<refentry id="sql-alterlargeobject">
  <indexterm zone="sql-alterlargeobject">
   <primary>ALTER LARGE OBJECT</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_materialized_view.sgml b/doc/src/sgml/ref/alter_materialized_view.sgml
index eaea819744a..f41b5058ff3 100644
--- a/doc/src/sgml/ref/alter_materialized_view.sgml
+++ b/doc/src/sgml/ref/alter_materialized_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_materialized_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERMATERIALIZEDVIEW">
+<refentry id="sql-altermaterializedview">
  <indexterm zone="sql-altermaterializedview">
   <primary>ALTER MATERIALIZED VIEW</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_opclass.sgml b/doc/src/sgml/ref/alter_opclass.sgml
index 834f3e4231d..e69bcf2dd76 100644
--- a/doc/src/sgml/ref/alter_opclass.sgml
+++ b/doc/src/sgml/ref/alter_opclass.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_opclass.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTEROPCLASS">
+<refentry id="sql-alteropclass">
  <indexterm zone="sql-alteropclass">
   <primary>ALTER OPERATOR CLASS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_operator.sgml b/doc/src/sgml/ref/alter_operator.sgml
index 3cc28d5b18a..4c6f75efff3 100644
--- a/doc/src/sgml/ref/alter_operator.sgml
+++ b/doc/src/sgml/ref/alter_operator.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_operator.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTEROPERATOR">
+<refentry id="sql-alteroperator">
  <indexterm zone="sql-alteroperator">
   <primary>ALTER OPERATOR</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_opfamily.sgml b/doc/src/sgml/ref/alter_opfamily.sgml
index d15fbfceea8..f327267ff81 100644
--- a/doc/src/sgml/ref/alter_opfamily.sgml
+++ b/doc/src/sgml/ref/alter_opfamily.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_opfamily.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTEROPFAMILY">
+<refentry id="sql-alteropfamily">
  <indexterm zone="sql-alteropfamily">
   <primary>ALTER OPERATOR FAMILY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_policy.sgml b/doc/src/sgml/ref/alter_policy.sgml
index 3eb91556023..a49f2fc5a5f 100644
--- a/doc/src/sgml/ref/alter_policy.sgml
+++ b/doc/src/sgml/ref/alter_policy.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_policy.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERPOLICY">
+<refentry id="sql-alterpolicy">
  <indexterm zone="sql-alterpolicy">
   <primary>ALTER POLICY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_publication.sgml b/doc/src/sgml/ref/alter_publication.sgml
index 801404e0cf9..5557f9b2318 100644
--- a/doc/src/sgml/ref/alter_publication.sgml
+++ b/doc/src/sgml/ref/alter_publication.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_publication.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERPUBLICATION">
+<refentry id="sql-alterpublication">
  <indexterm zone="sql-alterpublication">
   <primary>ALTER PUBLICATION</primary>
  </indexterm>
@@ -101,7 +101,7 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
     <listitem>
      <para>
       This clause alters publication parameters originally set by
-      <xref linkend="SQL-CREATEPUBLICATION">.  See there for more information.
+      <xref linkend="sql-createpublication">.  See there for more information.
      </para>
     </listitem>
    </varlistentry>
diff --git a/doc/src/sgml/ref/alter_role.sgml b/doc/src/sgml/ref/alter_role.sgml
index e30ca104549..c135364d4ec 100644
--- a/doc/src/sgml/ref/alter_role.sgml
+++ b/doc/src/sgml/ref/alter_role.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_role.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERROLE">
+<refentry id="sql-alterrole">
  <indexterm zone="sql-alterrole">
   <primary>ALTER ROLE</primary>
  </indexterm>
@@ -65,8 +65,8 @@ ALTER ROLE { <replaceable class="parameter">role_specification</replaceable> | A
    <xref linkend="sql-createrole">.
    (All the possible attributes are covered,
    except that there are no options for adding or removing memberships; use
-   <xref linkend="SQL-GRANT"> and
-   <xref linkend="SQL-REVOKE"> for that.)
+   <xref linkend="sql-grant"> and
+   <xref linkend="sql-revoke"> for that.)
    Attributes not mentioned in the command retain their previous settings.
    Database superusers can change any of these settings for any role.
    Roles having <literal>CREATEROLE</literal> privilege can change any of these
@@ -173,7 +173,7 @@ ALTER ROLE { <replaceable class="parameter">role_specification</replaceable> | A
       <listitem>
        <para>
         These clauses alter attributes originally set by
-        <xref linkend="SQL-CREATEROLE">. For more information, see the
+        <xref linkend="sql-createrole">. For more information, see the
         <command>CREATE ROLE</command> reference page.
        </para>
       </listitem>
@@ -236,14 +236,14 @@ ALTER ROLE { <replaceable class="parameter">role_specification</replaceable> | A
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-CREATEROLE">
-   to add new roles, and <xref linkend="SQL-DROPROLE"> to remove a role.
+   Use <xref linkend="sql-createrole">
+   to add new roles, and <xref linkend="sql-droprole"> to remove a role.
   </para>
 
   <para>
    <command>ALTER ROLE</command> cannot change a role's memberships.
-   Use <xref linkend="SQL-GRANT"> and
-   <xref linkend="SQL-REVOKE">
+   Use <xref linkend="sql-grant"> and
+   <xref linkend="sql-revoke">
    to do that.
   </para>
 
diff --git a/doc/src/sgml/ref/alter_rule.sgml b/doc/src/sgml/ref/alter_rule.sgml
index 26791b379bd..f8833feee71 100644
--- a/doc/src/sgml/ref/alter_rule.sgml
+++ b/doc/src/sgml/ref/alter_rule.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_rule.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERRULE">
+<refentry id="sql-alterrule">
  <indexterm zone="sql-alterrule">
   <primary>ALTER RULE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_schema.sgml b/doc/src/sgml/ref/alter_schema.sgml
index 2ca406b9148..dc914209545 100644
--- a/doc/src/sgml/ref/alter_schema.sgml
+++ b/doc/src/sgml/ref/alter_schema.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_schema.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSCHEMA">
+<refentry id="sql-alterschema">
  <indexterm zone="sql-alterschema">
   <primary>ALTER SCHEMA</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_sequence.sgml b/doc/src/sgml/ref/alter_sequence.sgml
index 9b8ad365227..655b35c6fcd 100644
--- a/doc/src/sgml/ref/alter_sequence.sgml
+++ b/doc/src/sgml/ref/alter_sequence.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_sequence.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSEQUENCE">
+<refentry id="sql-altersequence">
  <indexterm zone="sql-altersequence">
   <primary>ALTER SEQUENCE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_server.sgml b/doc/src/sgml/ref/alter_server.sgml
index 05e11f5ef28..53529abff7e 100644
--- a/doc/src/sgml/ref/alter_server.sgml
+++ b/doc/src/sgml/ref/alter_server.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_server.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSERVER">
+<refentry id="sql-alterserver">
  <indexterm zone="sql-alterserver">
   <primary>ALTER SERVER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_statistics.sgml b/doc/src/sgml/ref/alter_statistics.sgml
index 87acb879b03..d7b012fd543 100644
--- a/doc/src/sgml/ref/alter_statistics.sgml
+++ b/doc/src/sgml/ref/alter_statistics.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_statistics.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSTATISTICS">
+<refentry id="sql-alterstatistics">
  <indexterm zone="sql-alterstatistics">
   <primary>ALTER STATISTICS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml
index b76a21f6545..7e0240d696e 100644
--- a/doc/src/sgml/ref/alter_subscription.sgml
+++ b/doc/src/sgml/ref/alter_subscription.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_subscription.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSUBSCRIPTION">
+<refentry id="sql-altersubscription">
  <indexterm zone="sql-altersubscription">
   <primary>ALTER SUBSCRIPTION</primary>
  </indexterm>
@@ -68,7 +68,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
     <listitem>
      <para>
       This clause alters the connection property originally set by
-      <xref linkend="SQL-CREATESUBSCRIPTION">.  See there for more
+      <xref linkend="sql-createsubscription">.  See there for more
       information.
      </para>
     </listitem>
@@ -79,7 +79,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
     <listitem>
      <para>
       Changes list of subscribed publications. See
-      <xref linkend="SQL-CREATESUBSCRIPTION"> for more information.
+      <xref linkend="sql-createsubscription"> for more information.
       By default this command will also act like <literal>REFRESH
       PUBLICATION</literal>.
      </para>
@@ -162,7 +162,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
     <listitem>
      <para>
       This clause alters parameters originally set by
-      <xref linkend="SQL-CREATESUBSCRIPTION">.  See there for more
+      <xref linkend="sql-createsubscription">.  See there for more
       information.  The allowed options are <literal>slot_name</literal> and
       <literal>synchronous_commit</literal>
      </para>
diff --git a/doc/src/sgml/ref/alter_system.sgml b/doc/src/sgml/ref/alter_system.sgml
index b8ef117b7d7..887c4392dd5 100644
--- a/doc/src/sgml/ref/alter_system.sgml
+++ b/doc/src/sgml/ref/alter_system.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_system.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERSYSTEM">
+<refentry id="sql-altersystem">
  <indexterm zone="sql-altersystem">
   <primary>ALTER SYSTEM</primary>
  </indexterm>
@@ -135,8 +135,8 @@ ALTER SYSTEM RESET wal_level;
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="SQL-SET"></member>
-   <member><xref linkend="SQL-SHOW"></member>
+   <member><xref linkend="sql-set"></member>
+   <member><xref linkend="sql-show"></member>
   </simplelist>
  </refsect1>
 
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index b4b8dab9112..234ccb70e1c 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_table.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTABLE">
+<refentry id="sql-altertable">
  <indexterm zone="sql-altertable">
   <primary>ALTER TABLE</primary>
  </indexterm>
@@ -109,7 +109,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form adds a new column to the table, using the same syntax as
-      <xref linkend="SQL-CREATETABLE">. If <literal>IF NOT EXISTS</literal>
+      <xref linkend="sql-createtable">. If <literal>IF NOT EXISTS</literal>
       is specified and a column already exists with this name,
       no error is thrown.
      </para>
@@ -314,7 +314,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form adds a new constraint to a table using the same syntax as
-      <xref linkend="SQL-CREATETABLE">, plus the option <literal>NOT
+      <xref linkend="sql-createtable">, plus the option <literal>NOT
       VALID</literal>, which is currently only allowed for foreign key
       and CHECK constraints.
       If the constraint is marked <literal>NOT VALID</literal>, the
@@ -483,7 +483,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
       even if row level security is disabled - in this case, the policies will
       NOT be applied and the policies will be ignored.
       See also
-      <xref linkend="SQL-CREATEPOLICY">.
+      <xref linkend="sql-createpolicy">.
      </para>
     </listitem>
    </varlistentry>
@@ -498,7 +498,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
       disabled (the default) then row level security will not be applied when
       the user is the table owner.
       See also
-      <xref linkend="SQL-CREATEPOLICY">.
+      <xref linkend="sql-createpolicy">.
      </para>
     </listitem>
    </varlistentry>
@@ -508,7 +508,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form selects the default index for future
-      <xref linkend="SQL-CLUSTER">
+      <xref linkend="sql-cluster">
       operations.  It does not actually re-cluster the table.
      </para>
      <para>
@@ -522,7 +522,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form removes the most recently used
-      <xref linkend="SQL-CLUSTER">
+      <xref linkend="sql-cluster">
       index specification from the table.  This affects
       future cluster operations that don't specify an index.
      </para>
@@ -582,7 +582,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
       <literal>information_schema</literal> relations are not considered part
       of the system catalogs and will be moved.
       See also
-      <xref linkend="SQL-CREATETABLESPACE">.
+      <xref linkend="sql-createtablespace">.
      </para>
     </listitem>
    </varlistentry>
@@ -592,7 +592,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form changes the table from unlogged to logged or vice-versa
-      (see <xref linkend="SQL-CREATETABLE-UNLOGGED">).  It cannot be applied
+      (see <xref linkend="sql-createtable-unlogged">).  It cannot be applied
       to a temporary table.
      </para>
     </listitem>
@@ -603,13 +603,13 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     <listitem>
      <para>
       This form changes one or more storage parameters for the table.  See
-      <xref linkend="SQL-CREATETABLE-storage-parameters"
-      endterm="SQL-CREATETABLE-storage-parameters-title">
+      <xref linkend="sql-createtable-storage-parameters"
+      endterm="sql-createtable-storage-parameters-title">
       for details on the available parameters.  Note that the table contents
       will not be modified immediately by this command; depending on the
       parameter you might need to rewrite the table to get the desired effects.
-      That can be done with <link linkend="SQL-VACUUM">VACUUM
-      FULL</link>, <xref linkend="SQL-CLUSTER"> or one of the forms
+      That can be done with <link linkend="sql-vacuum">VACUUM
+      FULL</link>, <xref linkend="sql-cluster"> or one of the forms
       of <command>ALTER TABLE</command> that forces a table rewrite.
       For planner related parameters, changes will take effect from the next
       time the table is locked so currently executing queries will not be
@@ -722,7 +722,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
     </listitem>
    </varlistentry>
 
-   <varlistentry id="SQL-CREATETABLE-REPLICA-IDENTITY">
+   <varlistentry id="sql-createtable-replica-identity">
     <term><literal>REPLICA IDENTITY</literal></term>
     <listitem>
      <para>
@@ -810,7 +810,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
      <para>
       If the new partition is a foreign table, nothing is done to verify
       that all the rows in the foreign table obey the partition constraint.
-      (See the discussion in <xref linkend="SQL-CREATEFOREIGNTABLE"> about
+      (See the discussion in <xref linkend="sql-createforeigntable"> about
       constraints on the foreign table.)
      </para>
 
diff --git a/doc/src/sgml/ref/alter_tablespace.sgml b/doc/src/sgml/ref/alter_tablespace.sgml
index def554bfb33..4d6f011e2fb 100644
--- a/doc/src/sgml/ref/alter_tablespace.sgml
+++ b/doc/src/sgml/ref/alter_tablespace.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_tablespace.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTABLESPACE">
+<refentry id="sql-altertablespace">
  <indexterm zone="sql-altertablespace">
   <primary>ALTER TABLESPACE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_trigger.sgml b/doc/src/sgml/ref/alter_trigger.sgml
index 2e872cf11f2..4b4dacbf28d 100644
--- a/doc/src/sgml/ref/alter_trigger.sgml
+++ b/doc/src/sgml/ref/alter_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTRIGGER">
+<refentry id="sql-altertrigger">
  <indexterm zone="sql-altertrigger">
   <primary>ALTER TRIGGER</primary>
  </indexterm>
@@ -90,7 +90,7 @@ ALTER TRIGGER <replaceable class="parameter">name</replaceable> ON <replaceable
 
    <para>
     The ability to temporarily enable or disable a trigger is provided by
-    <xref linkend="SQL-ALTERTABLE">, not by
+    <xref linkend="sql-altertable">, not by
     <command>ALTER TRIGGER</command>, because <command>ALTER TRIGGER</command> has no
     convenient way to express the option of enabling or disabling all of
     a table's triggers at once.
diff --git a/doc/src/sgml/ref/alter_tsconfig.sgml b/doc/src/sgml/ref/alter_tsconfig.sgml
index b44aac9bf58..630927c15ba 100644
--- a/doc/src/sgml/ref/alter_tsconfig.sgml
+++ b/doc/src/sgml/ref/alter_tsconfig.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_tsconfig.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTSCONFIG">
+<refentry id="sql-altertsconfig">
  <indexterm zone="sql-altertsconfig">
   <primary>ALTER TEXT SEARCH CONFIGURATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_tsdictionary.sgml b/doc/src/sgml/ref/alter_tsdictionary.sgml
index 16d76687ab1..75a8b1dac62 100644
--- a/doc/src/sgml/ref/alter_tsdictionary.sgml
+++ b/doc/src/sgml/ref/alter_tsdictionary.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_tsdictionary.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTSDICTIONARY">
+<refentry id="sql-altertsdictionary">
  <indexterm zone="sql-altertsdictionary">
   <primary>ALTER TEXT SEARCH DICTIONARY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_tsparser.sgml b/doc/src/sgml/ref/alter_tsparser.sgml
index 737a5075657..c71faeec050 100644
--- a/doc/src/sgml/ref/alter_tsparser.sgml
+++ b/doc/src/sgml/ref/alter_tsparser.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_tsparser.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTSPARSER">
+<refentry id="sql-altertsparser">
  <indexterm zone="sql-altertsparser">
   <primary>ALTER TEXT SEARCH PARSER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_tstemplate.sgml b/doc/src/sgml/ref/alter_tstemplate.sgml
index d9a753017b5..210baa7125c 100644
--- a/doc/src/sgml/ref/alter_tstemplate.sgml
+++ b/doc/src/sgml/ref/alter_tstemplate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_tstemplate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTSTEMPLATE">
+<refentry id="sql-altertstemplate">
  <indexterm zone="sql-altertstemplate">
   <primary>ALTER TEXT SEARCH TEMPLATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_type.sgml b/doc/src/sgml/ref/alter_type.sgml
index 75be3187f14..7c32f0c5d5a 100644
--- a/doc/src/sgml/ref/alter_type.sgml
+++ b/doc/src/sgml/ref/alter_type.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_type.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERTYPE">
+<refentry id="sql-altertype">
  <indexterm zone="sql-altertype">
   <primary>ALTER TYPE</primary>
  </indexterm>
@@ -52,7 +52,7 @@ ALTER TYPE <replaceable class="parameter">name</replaceable> RENAME VALUE <repla
     <listitem>
      <para>
       This form adds a new attribute to a composite type, using the same syntax as
-      <xref linkend="SQL-CREATETYPE">.
+      <xref linkend="sql-createtype">.
      </para>
     </listitem>
    </varlistentry>
@@ -364,7 +364,7 @@ ALTER TYPE colors RENAME VALUE 'purple' TO 'mauve';
   </para>
  </refsect1>
 
- <refsect1 id="SQL-ALTERTYPE-see-also">
+ <refsect1 id="sql-altertype-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml
index 1a240ff4301..8e03510bd4e 100644
--- a/doc/src/sgml/ref/alter_user.sgml
+++ b/doc/src/sgml/ref/alter_user.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_user.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERUSER">
+<refentry id="sql-alteruser">
  <indexterm zone="sql-alteruser">
   <primary>ALTER USER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_user_mapping.sgml b/doc/src/sgml/ref/alter_user_mapping.sgml
index 18271d51995..eecff388cb0 100644
--- a/doc/src/sgml/ref/alter_user_mapping.sgml
+++ b/doc/src/sgml/ref/alter_user_mapping.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_user_mapping.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERUSERMAPPING">
+<refentry id="sql-alterusermapping">
  <indexterm zone="sql-alterusermapping">
   <primary>ALTER USER MAPPING</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/alter_view.sgml b/doc/src/sgml/ref/alter_view.sgml
index e7180b44093..f33519bd79a 100644
--- a/doc/src/sgml/ref/alter_view.sgml
+++ b/doc/src/sgml/ref/alter_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/alter_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ALTERVIEW">
+<refentry id="sql-alterview">
  <indexterm zone="sql-alterview">
   <primary>ALTER VIEW</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/analyze.sgml b/doc/src/sgml/ref/analyze.sgml
index 12f2f093372..bc33f0fa236 100644
--- a/doc/src/sgml/ref/analyze.sgml
+++ b/doc/src/sgml/ref/analyze.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/analyze.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ANALYZE">
+<refentry id="sql-analyze">
  <indexterm zone="sql-analyze">
   <primary>ANALYZE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/begin.sgml b/doc/src/sgml/ref/begin.sgml
index fd6f073d18e..45f85aea34e 100644
--- a/doc/src/sgml/ref/begin.sgml
+++ b/doc/src/sgml/ref/begin.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/begin.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-BEGIN">
+<refentry id="sql-begin">
  <indexterm zone="sql-begin">
   <primary>BEGIN</primary>
  </indexterm>
@@ -95,8 +95,8 @@ BEGIN [ WORK | TRANSACTION ] [ <replaceable class="parameter">transaction_mode</
   </para>
 
   <para>
-   Use <xref linkend="SQL-COMMIT"> or
-   <xref linkend="SQL-ROLLBACK">
+   Use <xref linkend="sql-commit"> or
+   <xref linkend="sql-rollback">
    to terminate a transaction block.
   </para>
 
diff --git a/doc/src/sgml/ref/close.sgml b/doc/src/sgml/ref/close.sgml
index 4d71c45797d..7ecc0cc4632 100644
--- a/doc/src/sgml/ref/close.sgml
+++ b/doc/src/sgml/ref/close.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/close.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CLOSE">
+<refentry id="sql-close">
  <indexterm zone="sql-close">
   <primary>CLOSE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml
index 5c5db750771..1210b5dffbf 100644
--- a/doc/src/sgml/ref/cluster.sgml
+++ b/doc/src/sgml/ref/cluster.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/cluster.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CLUSTER">
+<refentry id="sql-cluster">
  <indexterm zone="sql-cluster">
   <primary>CLUSTER</primary>
  </indexterm>
@@ -57,7 +57,7 @@ CLUSTER [VERBOSE]
    <command>CLUSTER <replaceable class="parameter">table_name</replaceable></command>
    reclusters the table using the same index as before.  You can also
    use the <literal>CLUSTER</literal> or <literal>SET WITHOUT CLUSTER</literal>
-   forms of <xref linkend="SQL-ALTERTABLE"> to set the index to be used for
+   forms of <xref linkend="sql-altertable"> to set the index to be used for
    future cluster operations, or to clear any previous setting.
   </para>
 
diff --git a/doc/src/sgml/ref/clusterdb.sgml b/doc/src/sgml/ref/clusterdb.sgml
index 081bbc5f7a3..d2d4b52f48c 100644
--- a/doc/src/sgml/ref/clusterdb.sgml
+++ b/doc/src/sgml/ref/clusterdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/clusterdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-CLUSTERDB">
+<refentry id="app-clusterdb">
  <indexterm zone="app-clusterdb">
   <primary>clusterdb</primary>
  </indexterm>
@@ -60,7 +60,7 @@ PostgreSQL documentation
 
   <para>
    <application>clusterdb</application> is a wrapper around the SQL
-   command <xref linkend="SQL-CLUSTER">.
+   command <xref linkend="sql-cluster">.
    There is no effective difference between clustering databases via
    this utility and via other methods for accessing the server.
   </para>
@@ -289,8 +289,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-CLUSTER">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-cluster">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml
index ab2e09d5218..d705792a451 100644
--- a/doc/src/sgml/ref/comment.sgml
+++ b/doc/src/sgml/ref/comment.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/comment.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-COMMENT">
+<refentry id="sql-comment">
  <indexterm zone="sql-comment">
   <primary>COMMENT</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/commit.sgml b/doc/src/sgml/ref/commit.sgml
index 8e3f53957ee..e41d6ff3cfb 100644
--- a/doc/src/sgml/ref/commit.sgml
+++ b/doc/src/sgml/ref/commit.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/commit.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-COMMIT">
+<refentry id="sql-commit">
  <indexterm zone="sql-commit">
   <primary>COMMIT</primary>
  </indexterm>
@@ -55,7 +55,7 @@ COMMIT [ WORK | TRANSACTION ]
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-ROLLBACK"> to
+   Use <xref linkend="sql-rollback"> to
    abort a transaction.
   </para>
 
diff --git a/doc/src/sgml/ref/commit_prepared.sgml b/doc/src/sgml/ref/commit_prepared.sgml
index 35bbf85af7e..c200a3e5737 100644
--- a/doc/src/sgml/ref/commit_prepared.sgml
+++ b/doc/src/sgml/ref/commit_prepared.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/commit_prepared.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-COMMIT-PREPARED">
+<refentry id="sql-commit-prepared">
  <indexterm zone="sql-commit-prepared">
   <primary>COMMIT PREPARED</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
index 8f0974b2569..eb91ad971d7 100644
--- a/doc/src/sgml/ref/copy.sgml
+++ b/doc/src/sgml/ref/copy.sgml
@@ -4,7 +4,7 @@ PostgreSQL documentation
 -->
 
 
-<refentry id="SQL-COPY">
+<refentry id="sql-copy">
  <indexterm zone="sql-copy">
   <primary>COPY</primary>
  </indexterm>
@@ -451,7 +451,7 @@ COPY <replaceable class="parameter">count</replaceable>
    <para>
     Do not confuse <command>COPY</command> with the
     <application>psql</application> instruction
-    <command><link linkend="APP-PSQL-meta-commands-copy">\copy</link></command>. <command>\copy</command> invokes
+    <command><link linkend="app-psql-meta-commands-copy">\copy</link></command>. <command>\copy</command> invokes
     <command>COPY FROM STDIN</command> or <command>COPY TO
     STDOUT</command>, and then fetches/stores the data in a file
     accessible to the <application>psql</application> client. Thus,
diff --git a/doc/src/sgml/ref/create_aggregate.sgml b/doc/src/sgml/ref/create_aggregate.sgml
index 3de30fa5808..4a8cee80574 100644
--- a/doc/src/sgml/ref/create_aggregate.sgml
+++ b/doc/src/sgml/ref/create_aggregate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_aggregate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEAGGREGATE">
+<refentry id="sql-createaggregate">
  <indexterm zone="sql-createaggregate">
   <primary>CREATE AGGREGATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_cast.sgml b/doc/src/sgml/ref/create_cast.sgml
index 89af1e50519..cd4565e3368 100644
--- a/doc/src/sgml/ref/create_cast.sgml
+++ b/doc/src/sgml/ref/create_cast.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/create_cast.sgml -->
 
-<refentry id="SQL-CREATECAST">
+<refentry id="sql-createcast">
  <indexterm zone="sql-createcast">
   <primary>CREATE CAST</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_collation.sgml b/doc/src/sgml/ref/create_collation.sgml
index d4e99e925f0..cc76b040272 100644
--- a/doc/src/sgml/ref/create_collation.sgml
+++ b/doc/src/sgml/ref/create_collation.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/create_collation.sgml -->
 
-<refentry id="SQL-CREATECOLLATION">
+<refentry id="sql-createcollation">
  <indexterm zone="sql-createcollation">
   <primary>CREATE COLLATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_conversion.sgml b/doc/src/sgml/ref/create_conversion.sgml
index 03e0315eef7..44475eb30ea 100644
--- a/doc/src/sgml/ref/create_conversion.sgml
+++ b/doc/src/sgml/ref/create_conversion.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/create_conversion.sgml -->
 
-<refentry id="SQL-CREATECONVERSION">
+<refentry id="sql-createconversion">
  <indexterm zone="sql-createconversion">
   <primary>CREATE CONVERSION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml
index 8adfa3a37bf..3e35c776ead 100644
--- a/doc/src/sgml/ref/create_database.sgml
+++ b/doc/src/sgml/ref/create_database.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_database.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEDATABASE">
+<refentry id="sql-createdatabase">
  <indexterm zone="sql-createdatabase">
   <primary>CREATE DATABASE</primary>
  </indexterm>
@@ -45,7 +45,7 @@ CREATE DATABASE <replaceable class="parameter">name</replaceable>
   <para>
    To create a database, you must be a superuser or have the special
    <literal>CREATEDB</literal> privilege.
-   See <xref linkend="SQL-CREATEUSER">.
+   See <xref linkend="sql-createuser">.
   </para>
 
   <para>
@@ -203,11 +203,11 @@ CREATE DATABASE <replaceable class="parameter">name</replaceable>
    </para>
 
    <para>
-    Use <xref linkend="SQL-DROPDATABASE"> to remove a database.
+    Use <xref linkend="sql-dropdatabase"> to remove a database.
    </para>
 
    <para>
-    The program <xref linkend="APP-CREATEDB"> is a
+    The program <xref linkend="app-createdb"> is a
     wrapper program around this command, provided for convenience.
    </para>
 
diff --git a/doc/src/sgml/ref/create_domain.sgml b/doc/src/sgml/ref/create_domain.sgml
index 705ff55c49f..d38914e2888 100644
--- a/doc/src/sgml/ref/create_domain.sgml
+++ b/doc/src/sgml/ref/create_domain.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_domain.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEDOMAIN">
+<refentry id="sql-createdomain">
  <indexterm zone="sql-createdomain">
   <primary>CREATE DOMAIN</primary>
  </indexterm>
@@ -242,7 +242,7 @@ CREATE TABLE us_snail_addy (
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-CREATEDOMAIN-compatibility">
+ <refsect1 id="sql-createdomain-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -251,7 +251,7 @@ CREATE TABLE us_snail_addy (
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATEDOMAIN-see-also">
+ <refsect1 id="sql-createdomain-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/create_event_trigger.sgml b/doc/src/sgml/ref/create_event_trigger.sgml
index 9652f024121..42cd0656122 100644
--- a/doc/src/sgml/ref/create_event_trigger.sgml
+++ b/doc/src/sgml/ref/create_event_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_event_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEEVENTTRIGGER">
+<refentry id="sql-createeventtrigger">
  <indexterm zone="sql-createeventtrigger">
   <primary>CREATE EVENT TRIGGER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_extension.sgml b/doc/src/sgml/ref/create_extension.sgml
index a3a7892812a..3e0f849f5b5 100644
--- a/doc/src/sgml/ref/create_extension.sgml
+++ b/doc/src/sgml/ref/create_extension.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_extension.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEEXTENSION">
+<refentry id="sql-createextension">
  <indexterm zone="sql-createextension">
   <primary>CREATE EXTENSION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_foreign_data_wrapper.sgml b/doc/src/sgml/ref/create_foreign_data_wrapper.sgml
index 87403a55e3b..d9a1c187358 100644
--- a/doc/src/sgml/ref/create_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/create_foreign_data_wrapper.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_foreign_data_wrapper.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEFOREIGNDATAWRAPPER">
+<refentry id="sql-createforeigndatawrapper">
  <indexterm zone="sql-createforeigndatawrapper">
   <primary>CREATE FOREIGN DATA WRAPPER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index 47705fd187e..212c62ae1b7 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/create_foreign_table.sgml -->
 
-<refentry id="SQL-CREATEFOREIGNTABLE">
+<refentry id="sql-createforeigntable">
  <indexterm zone="sql-createforeigntable">
   <primary>CREATE FOREIGN TABLE</primary>
  </indexterm>
@@ -51,7 +51,7 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
 </synopsis>
  </refsynopsisdiv>
 
- <refsect1 id="SQL-CREATEFOREIGNTABLE-description">
+ <refsect1 id="sql-createforeigntable-description">
   <title>Description</title>
 
   <para>
@@ -252,7 +252,7 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
      <para>
       The name of an existing foreign server to use for the foreign table.
       For details on defining a server, see <xref
-      linkend="SQL-CREATESERVER">.
+      linkend="sql-createserver">.
      </para>
     </listitem>
    </varlistentry>
@@ -310,7 +310,7 @@ CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
    </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATEFOREIGNTABLE-examples">
+ <refsect1 id="sql-createforeigntable-examples">
   <title>Examples</title>
 
   <para>
@@ -342,8 +342,8 @@ CREATE FOREIGN TABLE measurement_y2016m07
 
  </refsect1>
 
- <refsect1 id="SQL-CREATEFOREIGNTABLE-compatibility">
-  <title id="SQL-CREATEFOREIGNTABLE-compatibility-title">Compatibility</title>
+ <refsect1 id="sql-createforeigntable-compatibility">
+  <title id="sql-createforeigntable-compatibility-title">Compatibility</title>
 
   <para>
    The <command>CREATE FOREIGN TABLE</command> command largely conforms to the
diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml
index 97cb9b7fc8a..970dc133595 100644
--- a/doc/src/sgml/ref/create_function.sgml
+++ b/doc/src/sgml/ref/create_function.sgml
@@ -2,7 +2,7 @@
 doc/src/sgml/ref/create_function.sgml
 -->
 
-<refentry id="SQL-CREATEFUNCTION">
+<refentry id="sql-createfunction">
  <indexterm zone="sql-createfunction">
   <primary>CREATE FUNCTION</primary>
  </indexterm>
@@ -543,7 +543,7 @@ CREATE [ OR REPLACE ] FUNCTION
        the SQL function. The string <replaceable
        class="parameter">obj_file</replaceable> is the name of the shared
        library file containing the compiled C function, and is interpreted
-       as for the <xref linkend="SQL-LOAD"> command.  The string
+       as for the <xref linkend="sql-load"> command.  The string
        <replaceable class="parameter">link_symbol</replaceable> is the
        function's link symbol, that is, the name of the function in the C
        language source code.  If the link symbol is omitted, it is assumed
diff --git a/doc/src/sgml/ref/create_group.sgml b/doc/src/sgml/ref/create_group.sgml
index 7896043a116..0382349404c 100644
--- a/doc/src/sgml/ref/create_group.sgml
+++ b/doc/src/sgml/ref/create_group.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_group.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEGROUP">
+<refentry id="sql-creategroup">
  <indexterm zone="sql-creategroup">
   <primary>CREATE GROUP</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml
index bb2601dc8c8..92c0090dfd4 100644
--- a/doc/src/sgml/ref/create_index.sgml
+++ b/doc/src/sgml/ref/create_index.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_index.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEINDEX">
+<refentry id="sql-createindex">
  <indexterm zone="sql-createindex">
   <primary>CREATE INDEX</primary>
  </indexterm>
@@ -120,8 +120,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
         updates, or deletes on the table; whereas a standard index build
         locks out writes (but not reads) on the table until it's done.
         There are several caveats to be aware of when using this option
-        &mdash; see <xref linkend="SQL-CREATEINDEX-CONCURRENTLY"
-        endterm="SQL-CREATEINDEX-CONCURRENTLY-title">.
+        &mdash; see <xref linkend="sql-createindex-concurrently"
+        endterm="sql-createindex-concurrently-title">.
        </para>
       </listitem>
      </varlistentry>
@@ -288,8 +288,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
 
     </variablelist>
 
-  <refsect2 id="SQL-CREATEINDEX-storage-parameters">
-   <title id="SQL-CREATEINDEX-storage-parameters-title">Index Storage Parameters</title>
+  <refsect2 id="sql-createindex-storage-parameters">
+   <title id="sql-createindex-storage-parameters-title">Index Storage Parameters</title>
 
    <para>
     The optional <literal>WITH</literal> clause specifies <firstterm>storage
@@ -409,10 +409,10 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
    </variablelist>
   </refsect2>
 
-  <refsect2 id="SQL-CREATEINDEX-CONCURRENTLY">
-   <title id="SQL-CREATEINDEX-CONCURRENTLY-title">Building Indexes Concurrently</title>
+  <refsect2 id="sql-createindex-concurrently">
+   <title id="sql-createindex-concurrently-title">Building Indexes Concurrently</title>
 
-   <indexterm zone="SQL-CREATEINDEX-CONCURRENTLY">
+   <indexterm zone="sql-createindex-concurrently">
    <primary>index</primary>
    <secondary>building concurrently</secondary>
    </indexterm>
diff --git a/doc/src/sgml/ref/create_language.sgml b/doc/src/sgml/ref/create_language.sgml
index 20d56a766f3..92dae40ecc6 100644
--- a/doc/src/sgml/ref/create_language.sgml
+++ b/doc/src/sgml/ref/create_language.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_language.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATELANGUAGE">
+<refentry id="sql-createlanguage">
  <indexterm zone="sql-createlanguage">
   <primary>CREATE LANGUAGE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_materialized_view.sgml b/doc/src/sgml/ref/create_materialized_view.sgml
index 126aa5666f8..8dd138f8161 100644
--- a/doc/src/sgml/ref/create_materialized_view.sgml
+++ b/doc/src/sgml/ref/create_materialized_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_materialized_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEMATERIALIZEDVIEW">
+<refentry id="sql-creatematerializedview">
  <indexterm zone="sql-creatematerializedview">
   <primary>CREATE MATERIALIZED VIEW</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_opclass.sgml b/doc/src/sgml/ref/create_opclass.sgml
index 08eb7f2a083..882100583e5 100644
--- a/doc/src/sgml/ref/create_opclass.sgml
+++ b/doc/src/sgml/ref/create_opclass.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_opclass.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEOPCLASS">
+<refentry id="sql-createopclass">
  <indexterm zone="sql-createopclass">
   <primary>CREATE OPERATOR CLASS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml
index 11c38fd38be..774616e244f 100644
--- a/doc/src/sgml/ref/create_operator.sgml
+++ b/doc/src/sgml/ref/create_operator.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_operator.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEOPERATOR">
+<refentry id="sql-createoperator">
  <indexterm zone="sql-createoperator">
   <primary>CREATE OPERATOR</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_opfamily.sgml b/doc/src/sgml/ref/create_opfamily.sgml
index ca5261b7a08..0953e238ce7 100644
--- a/doc/src/sgml/ref/create_opfamily.sgml
+++ b/doc/src/sgml/ref/create_opfamily.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_opfamily.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEOPFAMILY">
+<refentry id="sql-createopfamily">
  <indexterm zone="sql-createopfamily">
   <primary>CREATE OPERATOR FAMILY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_policy.sgml b/doc/src/sgml/ref/create_policy.sgml
index 1bcf2de4290..64d3a6baa6c 100644
--- a/doc/src/sgml/ref/create_policy.sgml
+++ b/doc/src/sgml/ref/create_policy.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_policy.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEPOLICY">
+<refentry id="sql-createpolicy">
  <indexterm zone="sql-createpolicy">
   <primary>CREATE POLICY</primary>
  </indexterm>
@@ -222,7 +222,7 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
 
    <variablelist>
 
-     <varlistentry id="SQL-CREATEPOLICY-ALL">
+     <varlistentry id="sql-createpolicy-all">
       <term><literal>ALL</literal></term>
       <listitem>
        <para>
@@ -253,7 +253,7 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
       </listitem>
      </varlistentry>
 
-     <varlistentry id="SQL-CREATEPOLICY-SELECT">
+     <varlistentry id="sql-createpolicy-select">
       <term><literal>SELECT</literal></term>
       <listitem>
        <para>
@@ -273,7 +273,7 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
       </listitem>
      </varlistentry>
 
-     <varlistentry id="SQL-CREATEPOLICY-INSERT">
+     <varlistentry id="sql-createpolicy-insert">
       <term><literal>INSERT</literal></term>
       <listitem>
        <para>
@@ -294,7 +294,7 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
       </listitem>
      </varlistentry>
 
-     <varlistentry id="SQL-CREATEPOLICY-UPDATE">
+     <varlistentry id="sql-createpolicy-update">
       <term><literal>UPDATE</literal></term>
       <listitem>
        <para>
@@ -353,7 +353,7 @@ CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable
       </listitem>
      </varlistentry>
 
-     <varlistentry id="SQL-CREATEPOLICY-DELETE">
+     <varlistentry id="sql-createpolicy-delete">
       <term><literal>DELETE</literal></term>
       <listitem>
        <para>
diff --git a/doc/src/sgml/ref/create_publication.sgml b/doc/src/sgml/ref/create_publication.sgml
index b997d387e77..55771d1d310 100644
--- a/doc/src/sgml/ref/create_publication.sgml
+++ b/doc/src/sgml/ref/create_publication.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_publication.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEPUBLICATION">
+<refentry id="sql-createpublication">
  <indexterm zone="sql-createpublication">
   <primary>CREATE PUBLICATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index 4a4061a2371..7c050a3addf 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_role.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEROLE">
+<refentry id="sql-createrole">
  <indexterm zone="sql-createrole">
   <primary>CREATE ROLE</primary>
  </indexterm>
@@ -329,8 +329,8 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ [ WITH ] <replac
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-ALTERROLE"> to
-   change the attributes of a role, and <xref linkend="SQL-DROPROLE">
+   Use <xref linkend="sql-alterrole"> to
+   change the attributes of a role, and <xref linkend="sql-droprole">
    to remove a role.  All the attributes
    specified by <command>CREATE ROLE</command> can be modified by later
    <command>ALTER ROLE</command> commands.
@@ -339,8 +339,8 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ [ WITH ] <replac
   <para>
    The preferred way to add and remove members of roles that are being
    used as groups is to use
-   <xref linkend="SQL-GRANT"> and
-   <xref linkend="SQL-REVOKE">.
+   <xref linkend="sql-grant"> and
+   <xref linkend="sql-revoke">.
   </para>
 
   <para>
@@ -358,7 +358,7 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ [ WITH ] <replac
    a member of a role with <literal>CREATEDB</literal> privilege does not immediately
    grant the ability to create databases, even if <literal>INHERIT</literal> is set;
    it would be necessary to become that role via
-   <xref linkend="SQL-SET-ROLE"> before
+   <xref linkend="sql-set-role"> before
    creating a database.
   </para>
 
@@ -385,7 +385,7 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ [ WITH ] <replac
 
   <para>
    <productname>PostgreSQL</productname> includes a program <xref
-   linkend="APP-CREATEUSER"> that has
+   linkend="app-createuser"> that has
    the same functionality as <command>CREATE ROLE</command> (in fact,
    it calls this command) but can be run from the command shell.
   </para>
@@ -402,7 +402,7 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ [ WITH ] <replac
    with this command.  The password will be transmitted to the server
    in cleartext, and it might also be logged in the client's command
    history or the server log.  The command <xref
-   linkend="APP-CREATEUSER">, however, transmits
+   linkend="app-createuser">, however, transmits
    the password encrypted.  Also, <xref linkend="app-psql">
    contains a command
    <command>\password</command> that can be used to safely change the
diff --git a/doc/src/sgml/ref/create_rule.sgml b/doc/src/sgml/ref/create_rule.sgml
index c772c383991..c6403c05306 100644
--- a/doc/src/sgml/ref/create_rule.sgml
+++ b/doc/src/sgml/ref/create_rule.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_rule.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATERULE">
+<refentry id="sql-createrule">
  <indexterm zone="sql-createrule">
   <primary>CREATE RULE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_schema.sgml b/doc/src/sgml/ref/create_schema.sgml
index ce3530c0489..ed856e21e47 100644
--- a/doc/src/sgml/ref/create_schema.sgml
+++ b/doc/src/sgml/ref/create_schema.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_schema.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATESCHEMA">
+<refentry id="sql-createschema">
  <indexterm zone="sql-createschema">
   <primary>CREATE SCHEMA</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_sequence.sgml b/doc/src/sgml/ref/create_sequence.sgml
index 9248b1d459a..0cea9a49ce8 100644
--- a/doc/src/sgml/ref/create_sequence.sgml
+++ b/doc/src/sgml/ref/create_sequence.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_sequence.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATESEQUENCE">
+<refentry id="sql-createsequence">
  <indexterm zone="sql-createsequence">
   <primary>CREATE SEQUENCE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_server.sgml b/doc/src/sgml/ref/create_server.sgml
index e14ce43bf9e..e13636a2682 100644
--- a/doc/src/sgml/ref/create_server.sgml
+++ b/doc/src/sgml/ref/create_server.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_server.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATESERVER">
+<refentry id="sql-createserver">
  <indexterm zone="sql-createserver">
   <primary>CREATE SERVER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_statistics.sgml b/doc/src/sgml/ref/create_statistics.sgml
index 066af8a4b4d..bb99d8e785d 100644
--- a/doc/src/sgml/ref/create_statistics.sgml
+++ b/doc/src/sgml/ref/create_statistics.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_statistics.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATESTATISTICS">
+<refentry id="sql-createstatistics">
  <indexterm zone="sql-createstatistics">
   <primary>CREATE STATISTICS</primary>
  </indexterm>
@@ -29,7 +29,7 @@ CREATE STATISTICS [ IF NOT EXISTS ] <replaceable class="parameter">statistics_na
 
  </refsynopsisdiv>
 
- <refsect1 id="SQL-CREATESTATISTICS-description">
+ <refsect1 id="sql-createstatistics-description">
   <title>Description</title>
 
   <para>
@@ -125,7 +125,7 @@ CREATE STATISTICS [ IF NOT EXISTS ] <replaceable class="parameter">statistics_na
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATESTATISTICS-examples">
+ <refsect1 id="sql-createstatistics-examples">
   <title>Examples</title>
 
   <para>
diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml
index cd51b7fcac5..2a1514a5ac2 100644
--- a/doc/src/sgml/ref/create_subscription.sgml
+++ b/doc/src/sgml/ref/create_subscription.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_subscription.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATESUBSCRIPTION">
+<refentry id="sql-createsubscription">
  <indexterm zone="sql-createsubscription">
   <primary>CREATE SUBSCRIPTION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 2db2e9fc444..4f7b741526f 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_table.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETABLE">
+<refentry id="sql-createtable">
  <indexterm zone="sql-createtable">
   <primary>CREATE TABLE</primary>
  </indexterm>
@@ -102,7 +102,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
 
  </refsynopsisdiv>
 
- <refsect1 id="SQL-CREATETABLE-description">
+ <refsect1 id="sql-createtable-description">
   <title>Description</title>
 
   <para>
@@ -157,7 +157,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
 
   <variablelist>
 
-   <varlistentry id="SQL-CREATETABLE-TEMPORARY">
+   <varlistentry id="sql-createtable-temporary">
     <term><literal>TEMPORARY</literal> or <literal>TEMP</literal></term>
     <listitem>
      <para>
@@ -191,7 +191,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
     </listitem>
    </varlistentry>
 
-   <varlistentry id="SQL-CREATETABLE-UNLOGGED">
+   <varlistentry id="sql-createtable-unlogged">
     <term><literal>UNLOGGED</literal></term>
     <listitem>
      <para>
@@ -249,7 +249,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
     </listitem>
    </varlistentry>
 
-   <varlistentry id="SQL-CREATETABLE-PARTITION">
+   <varlistentry id="sql-createtable-partition">
     <term><literal>PARTITION OF <replaceable class="parameter">parent_table</replaceable> { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }</literal></term>
     <listitem>
      <para>
@@ -783,7 +783,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
     </listitem>
    </varlistentry>
 
-   <varlistentry id="SQL-CREATETABLE-EXCLUDE">
+   <varlistentry id="sql-createtable-exclude">
     <term><literal>EXCLUDE [ USING <replaceable class="parameter">index_method</replaceable> ] ( <replaceable class="parameter">exclude_element</replaceable> WITH <replaceable class="parameter">operator</replaceable> [, ... ] ) <replaceable class="parameter">index_parameters</replaceable> [ WHERE ( <replaceable class="parameter">predicate</replaceable> ) ]</literal></term>
     <listitem>
      <para>
@@ -1120,8 +1120,8 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
 
   </variablelist>
 
-  <refsect2 id="SQL-CREATETABLE-storage-parameters">
-   <title id="SQL-CREATETABLE-storage-parameters-title">Storage Parameters</title>
+  <refsect2 id="sql-createtable-storage-parameters">
+   <title id="sql-createtable-storage-parameters-title">Storage Parameters</title>
 
  <indexterm zone="sql-createtable-storage-parameters">
   <primary>storage parameters</primary>
@@ -1132,7 +1132,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
     for tables, and for indexes associated with a <literal>UNIQUE</literal>,
     <literal>PRIMARY KEY</literal>, or <literal>EXCLUDE</literal> constraint.
     Storage parameters for
-    indexes are documented in <xref linkend="SQL-CREATEINDEX">.
+    indexes are documented in <xref linkend="sql-createindex">.
     The storage parameters currently
     available for tables are listed below.  For many of these parameters, as
     shown, there is an additional parameter with the same name prefixed with
@@ -1360,7 +1360,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
   </refsect2>
  </refsect1>
 
- <refsect1 id="SQL-CREATETABLE-notes">
+ <refsect1 id="sql-createtable-notes">
   <title>Notes</title>
 
     <para>
@@ -1407,7 +1407,7 @@ FROM ( { <replaceable class="parameter">numeric_literal</replaceable> | <replace
  </refsect1>
 
 
- <refsect1 id="SQL-CREATETABLE-examples">
+ <refsect1 id="sql-createtable-examples">
   <title>Examples</title>
 
   <para>
@@ -1709,8 +1709,8 @@ CREATE TABLE cities_partdef
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-CREATETABLE-compatibility">
-  <title id="SQL-CREATETABLE-compatibility-title">Compatibility</title>
+ <refsect1 id="sql-createtable-compatibility">
+  <title id="sql-createtable-compatibility-title">Compatibility</title>
 
   <para>
    The <command>CREATE TABLE</command> command conforms to the
diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml
index 8198442a974..89ca82baa5c 100644
--- a/doc/src/sgml/ref/create_table_as.sgml
+++ b/doc/src/sgml/ref/create_table_as.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_table_as.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETABLEAS">
+<refentry id="sql-createtableas">
  <indexterm zone="sql-createtableas">
   <primary>CREATE TABLE AS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_tablespace.sgml b/doc/src/sgml/ref/create_tablespace.sgml
index 4d95cac9e59..ed9635ef400 100644
--- a/doc/src/sgml/ref/create_tablespace.sgml
+++ b/doc/src/sgml/ref/create_tablespace.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_tablespace.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETABLESPACE">
+<refentry id="sql-createtablespace">
  <indexterm zone="sql-createtablespace">
   <primary>CREATE TABLESPACE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_transform.sgml b/doc/src/sgml/ref/create_transform.sgml
index 647c3b9f057..dfb83a76da4 100644
--- a/doc/src/sgml/ref/create_transform.sgml
+++ b/doc/src/sgml/ref/create_transform.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/create_transform.sgml -->
 
-<refentry id="SQL-CREATETRANSFORM">
+<refentry id="sql-createtransform">
  <indexterm zone="sql-createtransform">
   <primary>CREATE TRANSFORM</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml
index 6726e3c7663..9e97c364ef8 100644
--- a/doc/src/sgml/ref/create_trigger.sgml
+++ b/doc/src/sgml/ref/create_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETRIGGER">
+<refentry id="sql-createtrigger">
  <indexterm zone="sql-createtrigger">
   <primary>CREATE TRIGGER</primary>
  </indexterm>
@@ -170,7 +170,7 @@ CREATE [ CONSTRAINT ] TRIGGER <replaceable class="parameter">name</replaceable>
    When the <literal>CONSTRAINT</literal> option is specified, this command creates a
    <firstterm>constraint trigger</firstterm>.  This is the same as a regular trigger
    except that the timing of the trigger firing can be adjusted using
-   <xref linkend="SQL-SET-CONSTRAINTS">.
+   <xref linkend="sql-set-constraints">.
    Constraint triggers must be <literal>AFTER ROW</literal> triggers on plain
    tables (not foreign tables).  They
    can be fired either at the end of the statement causing the triggering
@@ -302,7 +302,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
     <listitem>
      <para>
       The default timing of the trigger.
-      See the <xref linkend="SQL-CREATETABLE"> documentation for details of
+      See the <xref linkend="sql-createtable"> documentation for details of
       these constraint options.  This can only be specified for constraint
       triggers.
      </para>
@@ -422,7 +422,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-CREATETRIGGER-notes">
+ <refsect1 id="sql-createtrigger-notes">
   <title>Notes</title>
 
   <para>
@@ -523,7 +523,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATETRIGGER-examples">
+ <refsect1 id="sql-createtrigger-examples">
   <title>Examples</title>
 
   <para>
@@ -610,7 +610,7 @@ CREATE TRIGGER paired_items_update
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATETRIGGER-compatibility">
+ <refsect1 id="sql-createtrigger-compatibility">
   <title>Compatibility</title>
 
   <!--
diff --git a/doc/src/sgml/ref/create_tsconfig.sgml b/doc/src/sgml/ref/create_tsconfig.sgml
index d1792e5d29d..49634b43629 100644
--- a/doc/src/sgml/ref/create_tsconfig.sgml
+++ b/doc/src/sgml/ref/create_tsconfig.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_tsconfig.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETSCONFIG">
+<refentry id="sql-createtsconfig">
  <indexterm zone="sql-createtsconfig">
   <primary>CREATE TEXT SEARCH CONFIGURATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_tsdictionary.sgml b/doc/src/sgml/ref/create_tsdictionary.sgml
index 9c95c116083..20a01765b75 100644
--- a/doc/src/sgml/ref/create_tsdictionary.sgml
+++ b/doc/src/sgml/ref/create_tsdictionary.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_tsdictionary.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETSDICTIONARY">
+<refentry id="sql-createtsdictionary">
  <indexterm zone="sql-createtsdictionary">
   <primary>CREATE TEXT SEARCH DICTIONARY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_tsparser.sgml b/doc/src/sgml/ref/create_tsparser.sgml
index 044581f6f29..8e5e1b0b484 100644
--- a/doc/src/sgml/ref/create_tsparser.sgml
+++ b/doc/src/sgml/ref/create_tsparser.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_tsparser.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETSPARSER">
+<refentry id="sql-createtsparser">
  <indexterm zone="sql-createtsparser">
   <primary>CREATE TEXT SEARCH PARSER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_tstemplate.sgml b/doc/src/sgml/ref/create_tstemplate.sgml
index e10f18b28b8..0340e1ab1f4 100644
--- a/doc/src/sgml/ref/create_tstemplate.sgml
+++ b/doc/src/sgml/ref/create_tstemplate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_tstemplate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETSTEMPLATE">
+<refentry id="sql-createtstemplate">
  <indexterm zone="sql-createtstemplate">
   <primary>CREATE TEXT SEARCH TEMPLATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_type.sgml b/doc/src/sgml/ref/create_type.sgml
index 02ca27b281e..1b409ad22f6 100644
--- a/doc/src/sgml/ref/create_type.sgml
+++ b/doc/src/sgml/ref/create_type.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_type.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATETYPE">
+<refentry id="sql-createtype">
  <indexterm zone="sql-createtype">
   <primary>CREATE TYPE</primary>
  </indexterm>
@@ -111,7 +111,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
   </para>
   </refsect2>
 
-  <refsect2 id="SQL-CREATETYPE-enum">
+  <refsect2 id="sql-createtype-enum">
    <title>Enumerated Types</title>
 
    <para>
@@ -123,7 +123,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-CREATETYPE-RANGE">
+  <refsect2 id="sql-createtype-range">
    <title>Range Types</title>
 
    <para>
@@ -769,7 +769,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-CREATETYPE-notes">
+ <refsect1 id="sql-createtype-notes">
   <title>Notes</title>
 
   <para>
@@ -928,7 +928,7 @@ CREATE TABLE big_objs (
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATETYPE-compatibility">
+ <refsect1 id="sql-createtype-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -947,7 +947,7 @@ CREATE TABLE big_objs (
   </para>
  </refsect1>
 
- <refsect1 id="SQL-CREATETYPE-see-also">
+ <refsect1 id="sql-createtype-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/create_user.sgml b/doc/src/sgml/ref/create_user.sgml
index 500169da986..13dfd64c6d0 100644
--- a/doc/src/sgml/ref/create_user.sgml
+++ b/doc/src/sgml/ref/create_user.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_user.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEUSER">
+<refentry id="sql-createuser">
  <indexterm zone="sql-createuser">
   <primary>CREATE USER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_user_mapping.sgml b/doc/src/sgml/ref/create_user_mapping.sgml
index 10182e14266..d18cc91a002 100644
--- a/doc/src/sgml/ref/create_user_mapping.sgml
+++ b/doc/src/sgml/ref/create_user_mapping.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_user_mapping.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEUSERMAPPING">
+<refentry id="sql-createusermapping">
  <indexterm zone="sql-createusermapping">
   <primary>CREATE USER MAPPING</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml
index c0dd0224955..e52a4b85a77 100644
--- a/doc/src/sgml/ref/create_view.sgml
+++ b/doc/src/sgml/ref/create_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/create_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-CREATEVIEW">
+<refentry id="sql-createview">
  <indexterm zone="sql-createview">
   <primary>CREATE VIEW</primary>
  </indexterm>
@@ -165,10 +165,10 @@ CREATE VIEW [ <replaceable>schema</replaceable> . ] <replaceable>view_name</repl
 
    <varlistentry>
     <term><literal>WITH [ CASCADED | LOCAL ] CHECK OPTION</literal>
-      <indexterm zone="SQL-CREATEVIEW">
+      <indexterm zone="sql-createview">
        <primary>CHECK OPTION</primary>
       </indexterm>
-      <indexterm zone="SQL-CREATEVIEW">
+      <indexterm zone="sql-createview">
        <primary>WITH CHECK OPTION</primary>
       </indexterm>
     </term>
@@ -278,8 +278,8 @@ CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
     to replace it (this includes being a member of the owning role).
    </para>
 
-  <refsect2 id="SQL-CREATEVIEW-updatable-views">
-   <title id="SQL-CREATEVIEW-updatable-views-title">Updatable Views</title>
+  <refsect2 id="sql-createview-updatable-views">
+   <title id="sql-createview-updatable-views-title">Updatable Views</title>
 
    <indexterm zone="sql-createview-updatable-views">
     <primary>updatable views</primary>
diff --git a/doc/src/sgml/ref/createdb.sgml b/doc/src/sgml/ref/createdb.sgml
index 0112d3a848f..265d14e1491 100644
--- a/doc/src/sgml/ref/createdb.sgml
+++ b/doc/src/sgml/ref/createdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/createdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-CREATEDB">
+<refentry id="app-createdb">
  <indexterm zone="app-createdb">
   <primary>createdb</primary>
  </indexterm>
@@ -30,7 +30,7 @@ PostgreSQL documentation
  </refsynopsisdiv>
 
 
- <refsect1 id="R1-APP-CREATEDB-1">
+ <refsect1 id="r1-app-createdb-1">
   <title>
    Description
   </title>
@@ -48,7 +48,7 @@ PostgreSQL documentation
 
   <para>
    <application>createdb</application> is a wrapper around the
-   <acronym>SQL</acronym> command <xref linkend="SQL-CREATEDATABASE">.
+   <acronym>SQL</acronym> command <xref linkend="sql-createdatabase">.
    There is no effective difference between creating databases via
    this utility and via other methods for accessing the server.
   </para>
@@ -199,7 +199,7 @@ PostgreSQL documentation
     The options <option>-D</option>, <option>-l</option>, <option>-E</option>,
     <option>-O</option>, and
     <option>-T</option> correspond to options of the underlying
-    SQL command <xref linkend="SQL-CREATEDATABASE">; see there for more information
+    SQL command <xref linkend="sql-createdatabase">; see there for more information
     about them.
    </para>
 
@@ -337,8 +337,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-CREATEDATABASE">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-createdatabase">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml
index 788ee81dafb..f3c50c41131 100644
--- a/doc/src/sgml/ref/createuser.sgml
+++ b/doc/src/sgml/ref/createuser.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/createuser.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-CREATEUSER">
+<refentry id="app-createuser">
  <indexterm zone="app-createuser">
   <primary>createuser</primary>
  </indexterm>
@@ -49,7 +49,7 @@ PostgreSQL documentation
 
   <para>
    <application>createuser</application> is a wrapper around the
-   <acronym>SQL</acronym> command <xref linkend="SQL-CREATEROLE">.
+   <acronym>SQL</acronym> command <xref linkend="sql-createrole">.
    There is no effective difference between creating users via
    this utility and via other methods for accessing the server.
   </para>
@@ -415,8 +415,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-CREATEROLE">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-createrole">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/deallocate.sgml b/doc/src/sgml/ref/deallocate.sgml
index 394b125f523..4e23c6e091e 100644
--- a/doc/src/sgml/ref/deallocate.sgml
+++ b/doc/src/sgml/ref/deallocate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/deallocate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DEALLOCATE">
+<refentry id="sql-deallocate">
  <indexterm zone="sql-deallocate">
   <primary>DEALLOCATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/declare.sgml b/doc/src/sgml/ref/declare.sgml
index 8eae0354af8..a70e2466e5d 100644
--- a/doc/src/sgml/ref/declare.sgml
+++ b/doc/src/sgml/ref/declare.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/declare.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DECLARE">
+<refentry id="sql-declare">
  <indexterm zone="sql-declare">
   <primary>DECLARE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/delete.sgml b/doc/src/sgml/ref/delete.sgml
index 570e9aa7108..d7869efd9a2 100644
--- a/doc/src/sgml/ref/delete.sgml
+++ b/doc/src/sgml/ref/delete.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/delete.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DELETE">
+<refentry id="sql-delete">
  <indexterm zone="sql-delete">
   <primary>DELETE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/discard.sgml b/doc/src/sgml/ref/discard.sgml
index f432e70430d..063342494fa 100644
--- a/doc/src/sgml/ref/discard.sgml
+++ b/doc/src/sgml/ref/discard.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/discard.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DISCARD">
+<refentry id="sql-discard">
  <indexterm zone="sql-discard">
   <primary>DISCARD</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/do.sgml b/doc/src/sgml/ref/do.sgml
index 5d2e9b1b8ce..c14dff0a281 100644
--- a/doc/src/sgml/ref/do.sgml
+++ b/doc/src/sgml/ref/do.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/do.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DO">
+<refentry id="sql-do">
  <indexterm zone="sql-do">
   <primary>DO</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml
index ac29e7a4193..1e5b3e8bd47 100644
--- a/doc/src/sgml/ref/drop_aggregate.sgml
+++ b/doc/src/sgml/ref/drop_aggregate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_aggregate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPAGGREGATE">
+<refentry id="sql-dropaggregate">
  <indexterm zone="sql-dropaggregate">
   <primary>DROP AGGREGATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_cast.sgml b/doc/src/sgml/ref/drop_cast.sgml
index dae3a39fce2..6e0d7416371 100644
--- a/doc/src/sgml/ref/drop_cast.sgml
+++ b/doc/src/sgml/ref/drop_cast.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/drop_cast.sgml -->
 
-<refentry id="SQL-DROPCAST">
+<refentry id="sql-dropcast">
  <indexterm zone="sql-dropcast">
   <primary>DROP CAST</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_collation.sgml b/doc/src/sgml/ref/drop_collation.sgml
index 23f8e88fc95..03df0d17b1e 100644
--- a/doc/src/sgml/ref/drop_collation.sgml
+++ b/doc/src/sgml/ref/drop_collation.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/drop_collation.sgml -->
 
-<refentry id="SQL-DROPCOLLATION">
+<refentry id="sql-dropcollation">
  <indexterm zone="sql-dropcollation">
   <primary>DROP COLLATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_conversion.sgml b/doc/src/sgml/ref/drop_conversion.sgml
index 9d56ec51a59..d5cf18c3e91 100644
--- a/doc/src/sgml/ref/drop_conversion.sgml
+++ b/doc/src/sgml/ref/drop_conversion.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/drop_conversion.sgml -->
 
-<refentry id="SQL-DROPCONVERSION">
+<refentry id="sql-dropconversion">
  <indexterm zone="sql-dropconversion">
   <primary>DROP CONVERSION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_database.sgml b/doc/src/sgml/ref/drop_database.sgml
index 7e5fbe7396c..bbf3fd37769 100644
--- a/doc/src/sgml/ref/drop_database.sgml
+++ b/doc/src/sgml/ref/drop_database.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_database.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPDATABASE">
+<refentry id="sql-dropdatabase">
  <indexterm zone="sql-dropdatabase">
   <primary>DROP DATABASE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_domain.sgml b/doc/src/sgml/ref/drop_domain.sgml
index b1dac01e652..59379e82348 100644
--- a/doc/src/sgml/ref/drop_domain.sgml
+++ b/doc/src/sgml/ref/drop_domain.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_domain.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPDOMAIN">
+<refentry id="sql-dropdomain">
  <indexterm zone="sql-dropdomain">
   <primary>DROP DOMAIN</primary>
  </indexterm>
@@ -81,7 +81,7 @@ DROP DOMAIN [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, .
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-DROPDOMAIN-examples">
+ <refsect1 id="sql-dropdomain-examples">
   <title>Examples</title>
 
   <para>
@@ -92,7 +92,7 @@ DROP DOMAIN box;
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-DROPDOMAIN-compatibility">
+ <refsect1 id="sql-dropdomain-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -102,7 +102,7 @@ DROP DOMAIN box;
   </para>
  </refsect1>
 
- <refsect1 id="SQL-DROPDOMAIN-see-also">
+ <refsect1 id="sql-dropdomain-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/drop_event_trigger.sgml b/doc/src/sgml/ref/drop_event_trigger.sgml
index 583048dc0f4..a773170fa68 100644
--- a/doc/src/sgml/ref/drop_event_trigger.sgml
+++ b/doc/src/sgml/ref/drop_event_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_event_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPEVENTTRIGGER">
+<refentry id="sql-dropeventtrigger">
  <indexterm zone="sql-dropeventtrigger">
   <primary>DROP EVENT TRIGGER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_extension.sgml b/doc/src/sgml/ref/drop_extension.sgml
index f75308a20d3..bb296df17f3 100644
--- a/doc/src/sgml/ref/drop_extension.sgml
+++ b/doc/src/sgml/ref/drop_extension.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_extension.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPEXTENSION">
+<refentry id="sql-dropextension">
  <indexterm zone="sql-dropextension">
   <primary>DROP EXTENSION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
index a3c73a0d46b..8e8968ab1a6 100644
--- a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPFOREIGNDATAWRAPPER">
+<refentry id="sql-dropforeigndatawrapper">
  <indexterm zone="sql-dropforeigndatawrapper">
   <primary>DROP FOREIGN DATA WRAPPER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_foreign_table.sgml b/doc/src/sgml/ref/drop_foreign_table.sgml
index 456d55d1122..b12de03e65d 100644
--- a/doc/src/sgml/ref/drop_foreign_table.sgml
+++ b/doc/src/sgml/ref/drop_foreign_table.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/drop_foreign_table.sgml -->
 
-<refentry id="SQL-DROPFOREIGNTABLE">
+<refentry id="sql-dropforeigntable">
  <indexterm zone="sql-dropforeigntable">
   <primary>DROP FOREIGN TABLE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml
index 9c9adb9a46d..05b405dda17 100644
--- a/doc/src/sgml/ref/drop_function.sgml
+++ b/doc/src/sgml/ref/drop_function.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_function.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPFUNCTION">
+<refentry id="sql-dropfunction">
  <indexterm zone="sql-dropfunction">
   <primary>DROP FUNCTION</primary>
  </indexterm>
@@ -127,7 +127,7 @@ DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-DROPFUNCTION-examples">
+ <refsect1 id="sql-dropfunction-examples">
   <title>Examples</title>
 
   <para>
@@ -159,7 +159,7 @@ DROP FUNCTION update_employee_salaries();
   </para>
  </refsect1>
 
- <refsect1 id="SQL-DROPFUNCTION-compatibility">
+ <refsect1 id="sql-dropfunction-compatibility">
   <title>Compatibility</title>
 
   <para>
diff --git a/doc/src/sgml/ref/drop_group.sgml b/doc/src/sgml/ref/drop_group.sgml
index 5987c5f760b..7844db0f7d6 100644
--- a/doc/src/sgml/ref/drop_group.sgml
+++ b/doc/src/sgml/ref/drop_group.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_group.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPGROUP">
+<refentry id="sql-dropgroup">
  <indexterm zone="sql-dropgroup">
   <primary>DROP GROUP</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_index.sgml b/doc/src/sgml/ref/drop_index.sgml
index de36c135d16..fd235a0c276 100644
--- a/doc/src/sgml/ref/drop_index.sgml
+++ b/doc/src/sgml/ref/drop_index.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_index.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPINDEX">
+<refentry id="sql-dropindex">
  <indexterm zone="sql-dropindex">
   <primary>DROP INDEX</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_language.sgml b/doc/src/sgml/ref/drop_language.sgml
index 524d7583703..350375baef1 100644
--- a/doc/src/sgml/ref/drop_language.sgml
+++ b/doc/src/sgml/ref/drop_language.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_language.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPLANGUAGE">
+<refentry id="sql-droplanguage">
  <indexterm zone="sql-droplanguage">
   <primary>DROP LANGUAGE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_materialized_view.sgml b/doc/src/sgml/ref/drop_materialized_view.sgml
index a898a1fc0af..b115aceb384 100644
--- a/doc/src/sgml/ref/drop_materialized_view.sgml
+++ b/doc/src/sgml/ref/drop_materialized_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_materialized_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPMATERIALIZEDVIEW">
+<refentry id="sql-dropmaterializedview">
  <indexterm zone="sql-dropmaterializedview">
   <primary>DROP MATERIALIZED VIEW</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_opclass.sgml b/doc/src/sgml/ref/drop_opclass.sgml
index 83af6d7e485..53a40ff73ec 100644
--- a/doc/src/sgml/ref/drop_opclass.sgml
+++ b/doc/src/sgml/ref/drop_opclass.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_opclass.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPOPCLASS">
+<refentry id="sql-dropopclass">
  <indexterm zone="sql-dropopclass">
   <primary>DROP OPERATOR CLASS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 5897c99a620..b10bed09cc8 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_operator.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPOPERATOR">
+<refentry id="sql-dropoperator">
  <indexterm zone="sql-dropoperator">
   <primary>DROP OPERATOR</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_opfamily.sgml b/doc/src/sgml/ref/drop_opfamily.sgml
index b825978aee9..eb92664d85e 100644
--- a/doc/src/sgml/ref/drop_opfamily.sgml
+++ b/doc/src/sgml/ref/drop_opfamily.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_opfamily.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPOPFAMILY">
+<refentry id="sql-dropopfamily">
  <indexterm zone="sql-dropopfamily">
   <primary>DROP OPERATOR FAMILY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_owned.sgml b/doc/src/sgml/ref/drop_owned.sgml
index 8b4b3644e66..1eb054dee61 100644
--- a/doc/src/sgml/ref/drop_owned.sgml
+++ b/doc/src/sgml/ref/drop_owned.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_owned.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROP-OWNED">
+<refentry id="sql-drop-owned">
  <indexterm zone="sql-drop-owned">
   <primary>DROP OWNED</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_policy.sgml b/doc/src/sgml/ref/drop_policy.sgml
index f4746921054..2bc1e25f9c3 100644
--- a/doc/src/sgml/ref/drop_policy.sgml
+++ b/doc/src/sgml/ref/drop_policy.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_policy.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPPOLICY">
+<refentry id="sql-droppolicy">
  <indexterm zone="sql-droppolicy">
   <primary>DROP POLICY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_publication.sgml b/doc/src/sgml/ref/drop_publication.sgml
index 1c129c04443..3195c040bb3 100644
--- a/doc/src/sgml/ref/drop_publication.sgml
+++ b/doc/src/sgml/ref/drop_publication.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_publication.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPPUBLICATION">
+<refentry id="sql-droppublication">
  <indexterm zone="sql-droppublication">
   <primary>DROP PUBLICATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_role.sgml b/doc/src/sgml/ref/drop_role.sgml
index 3c1bbaba6fd..413d1870d42 100644
--- a/doc/src/sgml/ref/drop_role.sgml
+++ b/doc/src/sgml/ref/drop_role.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_role.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPROLE">
+<refentry id="sql-droprole">
  <indexterm zone="sql-droprole">
   <primary>DROP ROLE</primary>
  </indexterm>
@@ -83,7 +83,7 @@ DROP ROLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...
 
   <para>
    <productname>PostgreSQL</productname> includes a program <xref
-   linkend="APP-DROPUSER"> that has the
+   linkend="app-dropuser"> that has the
    same functionality as this command (in fact, it calls this command)
    but can be run from the command shell.
   </para>
diff --git a/doc/src/sgml/ref/drop_rule.sgml b/doc/src/sgml/ref/drop_rule.sgml
index d3fdf55080c..6955016c272 100644
--- a/doc/src/sgml/ref/drop_rule.sgml
+++ b/doc/src/sgml/ref/drop_rule.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_rule.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPRULE">
+<refentry id="sql-droprule">
  <indexterm zone="sql-droprule">
   <primary>DROP RULE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_schema.sgml b/doc/src/sgml/ref/drop_schema.sgml
index bb3af1e1863..2e608b2b207 100644
--- a/doc/src/sgml/ref/drop_schema.sgml
+++ b/doc/src/sgml/ref/drop_schema.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_schema.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPSCHEMA">
+<refentry id="sql-dropschema">
  <indexterm zone="sql-dropschema">
   <primary>DROP SCHEMA</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_sequence.sgml b/doc/src/sgml/ref/drop_sequence.sgml
index 5027129b38b..be30f8f8104 100644
--- a/doc/src/sgml/ref/drop_sequence.sgml
+++ b/doc/src/sgml/ref/drop_sequence.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_sequence.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPSEQUENCE">
+<refentry id="sql-dropsequence">
  <indexterm zone="sql-dropsequence">
   <primary>DROP SEQUENCE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_server.sgml b/doc/src/sgml/ref/drop_server.sgml
index 8ef0e014e4f..fa941e8cd20 100644
--- a/doc/src/sgml/ref/drop_server.sgml
+++ b/doc/src/sgml/ref/drop_server.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_server.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPSERVER">
+<refentry id="sql-dropserver">
  <indexterm zone="sql-dropserver">
   <primary>DROP SERVER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_statistics.sgml b/doc/src/sgml/ref/drop_statistics.sgml
index fd2087db6a7..b34d070d50c 100644
--- a/doc/src/sgml/ref/drop_statistics.sgml
+++ b/doc/src/sgml/ref/drop_statistics.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_statistics.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPSTATISTICS">
+<refentry id="sql-dropstatistics">
  <indexterm zone="sql-dropstatistics">
   <primary>DROP STATISTICS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_subscription.sgml b/doc/src/sgml/ref/drop_subscription.sgml
index 58b14894757..5ab2f9eae84 100644
--- a/doc/src/sgml/ref/drop_subscription.sgml
+++ b/doc/src/sgml/ref/drop_subscription.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_subscription.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPSUBSCRIPTION">
+<refentry id="sql-dropsubscription">
  <indexterm zone="sql-dropsubscription">
   <primary>DROP SUBSCRIPTION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_table.sgml b/doc/src/sgml/ref/drop_table.sgml
index cea7e003511..b2153699103 100644
--- a/doc/src/sgml/ref/drop_table.sgml
+++ b/doc/src/sgml/ref/drop_table.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_table.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTABLE">
+<refentry id="sql-droptable">
  <indexterm zone="sql-droptable">
   <primary>DROP TABLE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_tablespace.sgml b/doc/src/sgml/ref/drop_tablespace.sgml
index 4343035ebb2..b761a4d92e0 100644
--- a/doc/src/sgml/ref/drop_tablespace.sgml
+++ b/doc/src/sgml/ref/drop_tablespace.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_tablespace.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTABLESPACE">
+<refentry id="sql-droptablespace">
  <indexterm zone="sql-droptablespace">
   <primary>DROP TABLESPACE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_transform.sgml b/doc/src/sgml/ref/drop_transform.sgml
index 698920a2266..c7de707fcc4 100644
--- a/doc/src/sgml/ref/drop_transform.sgml
+++ b/doc/src/sgml/ref/drop_transform.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/drop_transform.sgml -->
 
-<refentry id="SQL-DROPTRANSFORM">
+<refentry id="sql-droptransform">
  <indexterm zone="sql-droptransform">
   <primary>DROP TRANSFORM</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_trigger.sgml b/doc/src/sgml/ref/drop_trigger.sgml
index d44bf138a67..118f38f3f48 100644
--- a/doc/src/sgml/ref/drop_trigger.sgml
+++ b/doc/src/sgml/ref/drop_trigger.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_trigger.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTRIGGER">
+<refentry id="sql-droptrigger">
  <indexterm zone="sql-droptrigger">
   <primary>DROP TRIGGER</primary>
  </indexterm>
@@ -92,7 +92,7 @@ DROP TRIGGER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ON
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-DROPTRIGGER-examples">
+ <refsect1 id="sql-droptrigger-examples">
   <title>Examples</title>
 
   <para>
@@ -104,7 +104,7 @@ DROP TRIGGER if_dist_exists ON films;
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-DROPTRIGGER-compatibility">
+ <refsect1 id="sql-droptrigger-compatibility">
   <title>Compatibility</title>
 
   <para>
diff --git a/doc/src/sgml/ref/drop_tsconfig.sgml b/doc/src/sgml/ref/drop_tsconfig.sgml
index cc053beceb7..b7acf46ff7a 100644
--- a/doc/src/sgml/ref/drop_tsconfig.sgml
+++ b/doc/src/sgml/ref/drop_tsconfig.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_tsconfig.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTSCONFIG">
+<refentry id="sql-droptsconfig">
  <indexterm zone="sql-droptsconfig">
   <primary>DROP TEXT SEARCH CONFIGURATION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_tsdictionary.sgml b/doc/src/sgml/ref/drop_tsdictionary.sgml
index 66af10fb0f4..b670f55ff2b 100644
--- a/doc/src/sgml/ref/drop_tsdictionary.sgml
+++ b/doc/src/sgml/ref/drop_tsdictionary.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_tsdictionary.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTSDICTIONARY">
+<refentry id="sql-droptsdictionary">
  <indexterm zone="sql-droptsdictionary">
   <primary>DROP TEXT SEARCH DICTIONARY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_tsparser.sgml b/doc/src/sgml/ref/drop_tsparser.sgml
index 3fa9467ebdd..dea9b2b1bda 100644
--- a/doc/src/sgml/ref/drop_tsparser.sgml
+++ b/doc/src/sgml/ref/drop_tsparser.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_tsparser.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTSPARSER">
+<refentry id="sql-droptsparser">
  <indexterm zone="sql-droptsparser">
   <primary>DROP TEXT SEARCH PARSER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_tstemplate.sgml b/doc/src/sgml/ref/drop_tstemplate.sgml
index ad832754573..244af48191e 100644
--- a/doc/src/sgml/ref/drop_tstemplate.sgml
+++ b/doc/src/sgml/ref/drop_tstemplate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_tstemplate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTSTEMPLATE">
+<refentry id="sql-droptstemplate">
  <indexterm zone="sql-droptstemplate">
   <primary>DROP TEXT SEARCH TEMPLATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_type.sgml b/doc/src/sgml/ref/drop_type.sgml
index 92ac2729caf..37449ed19fd 100644
--- a/doc/src/sgml/ref/drop_type.sgml
+++ b/doc/src/sgml/ref/drop_type.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_type.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPTYPE">
+<refentry id="sql-droptype">
  <indexterm zone="sql-droptype">
   <primary>DROP TYPE</primary>
  </indexterm>
@@ -81,7 +81,7 @@ DROP TYPE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-DROPTYPE-examples">
+ <refsect1 id="sql-droptype-examples">
   <title>Examples</title>
 
   <para>
@@ -91,7 +91,7 @@ DROP TYPE box;
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-DROPTYPE-compatibility">
+ <refsect1 id="sql-droptype-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -104,7 +104,7 @@ DROP TYPE box;
   </para>
  </refsect1>
 
- <refsect1 id="SQL-DROPTYPE-see-also">
+ <refsect1 id="sql-droptype-see-also">
   <title>See Also</title>
 
   <simplelist type="inline">
diff --git a/doc/src/sgml/ref/drop_user.sgml b/doc/src/sgml/ref/drop_user.sgml
index 3cb90522daa..0e680f30f63 100644
--- a/doc/src/sgml/ref/drop_user.sgml
+++ b/doc/src/sgml/ref/drop_user.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_user.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPUSER">
+<refentry id="sql-dropuser">
  <indexterm zone="sql-dropuser">
   <primary>DROP USER</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_user_mapping.sgml b/doc/src/sgml/ref/drop_user_mapping.sgml
index 27284acae4c..393a1eadcf6 100644
--- a/doc/src/sgml/ref/drop_user_mapping.sgml
+++ b/doc/src/sgml/ref/drop_user_mapping.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_user_mapping.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPUSERMAPPING">
+<refentry id="sql-dropusermapping">
  <indexterm zone="sql-dropusermapping">
   <primary>DROP USER MAPPING</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/drop_view.sgml b/doc/src/sgml/ref/drop_view.sgml
index a33b33335b0..47e55bffb47 100644
--- a/doc/src/sgml/ref/drop_view.sgml
+++ b/doc/src/sgml/ref/drop_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/drop_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-DROPVIEW">
+<refentry id="sql-dropview">
  <indexterm zone="sql-dropview">
   <primary>DROP VIEW</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/dropdb.sgml b/doc/src/sgml/ref/dropdb.sgml
index 9dd44be8828..f7ca0877b1d 100644
--- a/doc/src/sgml/ref/dropdb.sgml
+++ b/doc/src/sgml/ref/dropdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/dropdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-DROPDB">
+<refentry id="app-dropdb">
  <indexterm zone="app-dropdb">
   <primary>dropdb</primary>
  </indexterm>
@@ -41,7 +41,7 @@ PostgreSQL documentation
 
   <para>
    <application>dropdb</application> is a wrapper around the
-   <acronym>SQL</acronym> command <xref linkend="SQL-DROPDATABASE">.
+   <acronym>SQL</acronym> command <xref linkend="sql-dropdatabase">.
    There is no effective difference between dropping databases via
    this utility and via other methods for accessing the server.
   </para>
@@ -243,8 +243,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-DROPDATABASE">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-dropdatabase">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/dropuser.sgml b/doc/src/sgml/ref/dropuser.sgml
index 1387b7dc2da..4c6a8bdb409 100644
--- a/doc/src/sgml/ref/dropuser.sgml
+++ b/doc/src/sgml/ref/dropuser.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/dropuser.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-DROPUSER">
+<refentry id="app-dropuser">
  <indexterm zone="app-dropuser">
   <primary>dropuser</primary>
  </indexterm>
@@ -42,7 +42,7 @@ PostgreSQL documentation
 
   <para>
    <application>dropuser</application> is a wrapper around the
-   <acronym>SQL</acronym> command <xref linkend="SQL-DROPROLE">.
+   <acronym>SQL</acronym> command <xref linkend="sql-droprole">.
    There is no effective difference between dropping users via
    this utility and via other methods for accessing the server.
   </para>
@@ -235,8 +235,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-DROPROLE">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-droprole">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/ecpg-ref.sgml b/doc/src/sgml/ref/ecpg-ref.sgml
index a9eaff815dc..18e7ed526ae 100644
--- a/doc/src/sgml/ref/ecpg-ref.sgml
+++ b/doc/src/sgml/ref/ecpg-ref.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/ecpg-ref.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-ECPG">
+<refentry id="app-ecpg">
  <indexterm zone="app-ecpg">
   <primary>ecpg</primary>
  </indexterm>
@@ -28,7 +28,7 @@ PostgreSQL documentation
  </refsynopsisdiv>
 
 
- <refsect1 id="APP-ECPG-description">
+ <refsect1 id="app-ecpg-description">
   <title>Description</title>
 
   <para>
diff --git a/doc/src/sgml/ref/end.sgml b/doc/src/sgml/ref/end.sgml
index 1f74118efd9..4904980dab4 100644
--- a/doc/src/sgml/ref/end.sgml
+++ b/doc/src/sgml/ref/end.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/end.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-END">
+<refentry id="sql-end">
  <indexterm zone="sql-end">
   <primary>END</primary>
  </indexterm>
@@ -57,7 +57,7 @@ END [ WORK | TRANSACTION ]
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-ROLLBACK"> to
+   Use <xref linkend="sql-rollback"> to
    abort a transaction.
   </para>
 
diff --git a/doc/src/sgml/ref/execute.sgml b/doc/src/sgml/ref/execute.sgml
index 6ac413d8086..113a07a3ce5 100644
--- a/doc/src/sgml/ref/execute.sgml
+++ b/doc/src/sgml/ref/execute.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/execute.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-EXECUTE">
+<refentry id="sql-execute">
  <indexterm zone="sql-execute">
   <primary>EXECUTE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml
index bbf2e11cbb9..a32c1505111 100644
--- a/doc/src/sgml/ref/explain.sgml
+++ b/doc/src/sgml/ref/explain.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/explain.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-EXPLAIN">
+<refentry id="sql-explain">
  <indexterm zone="sql-explain">
   <primary>EXPLAIN</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/fetch.sgml b/doc/src/sgml/ref/fetch.sgml
index fb79a1ac61a..aa2e8f64b8a 100644
--- a/doc/src/sgml/ref/fetch.sgml
+++ b/doc/src/sgml/ref/fetch.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/fetch.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-FETCH">
+<refentry id="sql-fetch">
 
  <indexterm zone="sql-fetch">
   <primary>FETCH</primary>
diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index fd9fe03a6ad..475c85b835e 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/grant.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-GRANT">
+<refentry id="sql-grant">
  <indexterm zone="sql-grant">
   <primary>GRANT</primary>
  </indexterm>
@@ -429,7 +429,7 @@ GRANT <replaceable class="parameter">role_name</replaceable> [, ...] TO <replace
  </refsect1>
 
 
- <refsect1 id="SQL-GRANT-notes">
+ <refsect1 id="sql-grant-notes">
   <title>Notes</title>
 
    <para>
diff --git a/doc/src/sgml/ref/import_foreign_schema.sgml b/doc/src/sgml/ref/import_foreign_schema.sgml
index 9bc83f1c6a6..66c8462a5a8 100644
--- a/doc/src/sgml/ref/import_foreign_schema.sgml
+++ b/doc/src/sgml/ref/import_foreign_schema.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/import_foreign_schema.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-IMPORTFOREIGNSCHEMA">
+<refentry id="sql-importforeignschema">
  <indexterm zone="sql-importforeignschema">
   <primary>IMPORT FOREIGN SCHEMA</primary>
  </indexterm>
@@ -29,7 +29,7 @@ IMPORT FOREIGN SCHEMA <replaceable class="parameter">remote_schema</replaceable>
 </synopsis>
  </refsynopsisdiv>
 
- <refsect1 id="SQL-IMPORTFOREIGNSCHEMA-description">
+ <refsect1 id="sql-importforeignschema-description">
   <title>Description</title>
 
   <para>
@@ -120,7 +120,7 @@ IMPORT FOREIGN SCHEMA <replaceable class="parameter">remote_schema</replaceable>
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-IMPORTFOREIGNSCHEMA-examples">
+ <refsect1 id="sql-importforeignschema-examples">
   <title>Examples</title>
 
   <para>
@@ -144,7 +144,7 @@ IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-IMPORTFOREIGNSCHEMA-compatibility">
+ <refsect1 id="sql-importforeignschema-compatibility">
   <title>Compatibility</title>
 
   <para>
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml
index 6696d4d05ab..9a02bc1dbb1 100644
--- a/doc/src/sgml/ref/initdb.sgml
+++ b/doc/src/sgml/ref/initdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/initdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-INITDB">
+<refentry id="app-initdb">
  <indexterm zone="app-initdb">
   <primary>initdb</primary>
  </indexterm>
@@ -33,7 +33,7 @@ PostgreSQL documentation
   </cmdsynopsis>
  </refsynopsisdiv>
 
- <refsect1 id="R1-APP-INITDB-1">
+ <refsect1 id="r1-app-initdb-1">
   <title>
    Description
   </title>
diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml
index 7f44ec31d15..f13fad4dd68 100644
--- a/doc/src/sgml/ref/insert.sgml
+++ b/doc/src/sgml/ref/insert.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/insert.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-INSERT">
+<refentry id="sql-insert">
  <indexterm zone="sql-insert">
   <primary>INSERT</primary>
  </indexterm>
@@ -128,7 +128,7 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> [ AS <replac
  <refsect1>
   <title>Parameters</title>
 
-  <refsect2 id="SQL-INSERTING-PARAMS">
+  <refsect2 id="sql-inserting-params">
    <title id="sql-inserting-params-title">Inserting</title>
 
    <para>
@@ -304,10 +304,10 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> [ AS <replac
 
   <refsect2 id="sql-on-conflict">
    <title id="sql-on-conflict-title"><literal>ON CONFLICT</literal> Clause</title>
-   <indexterm zone="SQL-INSERT">
+   <indexterm zone="sql-insert">
     <primary>UPSERT</primary>
    </indexterm>
-   <indexterm zone="SQL-INSERT">
+   <indexterm zone="sql-insert">
     <primary>ON CONFLICT</primary>
    </indexterm>
    <para>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 65275627174..f4c25efbd04 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/listen.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-LISTEN">
+<refentry id="sql-listen">
  <indexterm zone="sql-listen">
   <primary>LISTEN</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/load.sgml b/doc/src/sgml/ref/load.sgml
index b9e3fe8b255..14886199dee 100644
--- a/doc/src/sgml/ref/load.sgml
+++ b/doc/src/sgml/ref/load.sgml
@@ -2,7 +2,7 @@
 doc/src/sgml/ref/load.sgml
 -->
 
-<refentry id="SQL-LOAD">
+<refentry id="sql-load">
  <indexterm zone="sql-load">
   <primary>LOAD</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml
index 6d68ec6c53b..49e29339386 100644
--- a/doc/src/sgml/ref/lock.sgml
+++ b/doc/src/sgml/ref/lock.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/lock.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-LOCK">
+<refentry id="sql-lock">
  <indexterm zone="sql-lock">
   <primary>LOCK</primary>
  </indexterm>
@@ -236,7 +236,7 @@ COMMIT WORK;
    There is no <command>LOCK TABLE</command> in the SQL standard,
    which instead uses <command>SET TRANSACTION</command> to specify
    concurrency levels on transactions.  <productname>PostgreSQL</productname> supports that too;
-   see <xref linkend="SQL-SET-TRANSACTION"> for details.
+   see <xref linkend="sql-set-transaction"> for details.
   </para>
 
   <para>
diff --git a/doc/src/sgml/ref/move.sgml b/doc/src/sgml/ref/move.sgml
index 4bf78968588..50533e5e0ea 100644
--- a/doc/src/sgml/ref/move.sgml
+++ b/doc/src/sgml/ref/move.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/move.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-MOVE">
+<refentry id="sql-move">
  <indexterm zone="sql-move">
   <primary>MOVE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index 4376b9fdd73..481163634fa 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/notify.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-NOTIFY">
+<refentry id="sql-notify">
  <indexterm zone="sql-notify">
   <primary>NOTIFY</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml
index 1944c185cb9..167d523f5dc 100644
--- a/doc/src/sgml/ref/pg_basebackup.sgml
+++ b/doc/src/sgml/ref/pg_basebackup.sgml
@@ -45,7 +45,7 @@ PostgreSQL documentation
    out of backup mode automatically. Backups are always taken of the entire
    database cluster; it is not possible to back up individual databases or
    database objects. For individual database backups, a tool such as
-   <xref linkend="APP-PGDUMP"> must be used.
+   <xref linkend="app-pgdump"> must be used.
   </para>
 
   <para>
@@ -768,7 +768,7 @@ PostgreSQL documentation
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="APP-PGDUMP"></member>
+   <member><xref linkend="app-pgdump"></member>
   </simplelist>
  </refsect1>
 
diff --git a/doc/src/sgml/ref/pg_controldata.sgml b/doc/src/sgml/ref/pg_controldata.sgml
index 4d4feacb931..9a676e0a78b 100644
--- a/doc/src/sgml/ref/pg_controldata.sgml
+++ b/doc/src/sgml/ref/pg_controldata.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/pg_controldata.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-PGCONTROLDATA">
+<refentry id="app-pgcontroldata">
  <indexterm zone="app-pgcontroldata">
   <primary>pg_controldata</primary>
  </indexterm>
@@ -27,7 +27,7 @@ PostgreSQL documentation
   </cmdsynopsis>
  </refsynopsisdiv>
 
- <refsect1 id="R1-APP-PGCONTROLDATA-1">
+ <refsect1 id="r1-app-pgcontroldata-1">
   <title>Description</title>
   <para>
    <command>pg_controldata</command> prints information initialized during
diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
index 3bcf0a2e9f0..f930c7e2452 100644
--- a/doc/src/sgml/ref/pg_ctl-ref.sgml
+++ b/doc/src/sgml/ref/pg_ctl-ref.sgml
@@ -610,10 +610,10 @@ PostgreSQL documentation
  </refsect1>
 
 
- <refsect1 id="R1-APP-PGCTL-2">
+ <refsect1 id="r1-app-pgctl-2">
   <title>Examples</title>
 
-  <refsect2 id="R2-APP-PGCTL-3">
+  <refsect2 id="r2-app-pgctl-3">
    <title>Starting the Server</title>
 
    <para>
@@ -632,7 +632,7 @@ PostgreSQL documentation
 </screen></para>
   </refsect2>
 
-  <refsect2 id="R2-APP-PGCTL-4">
+  <refsect2 id="r2-app-pgctl-4">
    <title>Stopping the Server</title>
    <para>
     To stop the server, use:
@@ -646,7 +646,7 @@ PostgreSQL documentation
 </screen></para>
   </refsect2>
 
-  <refsect2 id="R2-APP-PGCTL-5">
+  <refsect2 id="r2-app-pgctl-5">
    <title>Restarting the Server</title>
 
    <para>
@@ -668,7 +668,7 @@ PostgreSQL documentation
 </screen></para>
   </refsect2>
 
-  <refsect2 id="R2-APP-PGCTL-6">
+  <refsect2 id="r2-app-pgctl-6">
    <title>Showing the Server Status</title>
 
    <para>
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 79a9ee09830..57272e33bfe 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/pg_dump.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-PGDUMP">
+<refentry id="app-pgdump">
  <indexterm zone="app-pgdump">
   <primary>pg_dump</primary>
  </indexterm>
@@ -375,7 +375,7 @@ PostgreSQL documentation
         <replaceable class="parameter">schema</replaceable> parameter is
         interpreted as a pattern according to the same rules used by
         <application>psql</application>'s <literal>\d</literal> commands (see <xref
-        linkend="APP-PSQL-patterns" endterm="APP-PSQL-patterns-title">),
+        linkend="app-psql-patterns" endterm="app-psql-patterns-title">),
         so multiple schemas can also be selected by writing wildcard characters
         in the pattern.  When using wildcards, be careful to quote the pattern
         if needed to prevent the shell from expanding the wildcards;  see
@@ -526,7 +526,7 @@ PostgreSQL documentation
         <replaceable class="parameter">table</replaceable> parameter is
         interpreted as a pattern according to the same rules used by
         <application>psql</application>'s <literal>\d</literal> commands (see <xref
-        linkend="APP-PSQL-patterns" endterm="APP-PSQL-patterns-title">),
+        linkend="app-psql-patterns" endterm="app-psql-patterns-title">),
         so multiple tables can also be selected by writing wildcard characters
         in the pattern.  When using wildcards, be careful to quote the pattern
         if needed to prevent the shell from expanding the wildcards;  see
@@ -1374,7 +1374,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
    To specify an upper-case or mixed-case name in <option>-t</option> and related
    switches, you need to double-quote the name; else it will be folded to
    lower case (see <xref
-   linkend="APP-PSQL-patterns" endterm="APP-PSQL-patterns-title">).  But
+   linkend="app-psql-patterns" endterm="app-psql-patterns-title">).  But
    double quotes are special to the shell, so in turn they must be quoted.
    Thus, to dump a single table with a mixed-case name, you need something
    like
diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml
index 0a64c3548ef..ce6b895da28 100644
--- a/doc/src/sgml/ref/pg_dumpall.sgml
+++ b/doc/src/sgml/ref/pg_dumpall.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/pg_dumpall.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-PG-DUMPALL">
+<refentry id="app-pg-dumpall">
  <indexterm zone="app-pg-dumpall">
   <primary>pg_dumpall</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml
index 5395fde6d6a..4d13c57ffa0 100644
--- a/doc/src/sgml/ref/pg_receivewal.sgml
+++ b/doc/src/sgml/ref/pg_receivewal.sgml
@@ -426,7 +426,7 @@ PostgreSQL documentation
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="APP-PGBASEBACKUP"></member>
+   <member><xref linkend="app-pgbasebackup"></member>
   </simplelist>
  </refsect1>
 
diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml
index 5add6113f3b..86f660070f1 100644
--- a/doc/src/sgml/ref/pg_recvlogical.sgml
+++ b/doc/src/sgml/ref/pg_recvlogical.sgml
@@ -279,7 +279,7 @@ PostgreSQL documentation
         <para>
          The database to connect to.  See the description of the actions for
          what this means in detail.  This can be a <application>libpq</application> connection string;
-         see <xref linkend="LIBPQ-CONNSTRING"> for more information.  Defaults
+         see <xref linkend="libpq-connstring"> for more information.  Defaults
          to user name.
         </para>
        </listitem>
diff --git a/doc/src/sgml/ref/pg_resetwal.sgml b/doc/src/sgml/ref/pg_resetwal.sgml
index c8e5790a8e7..0c30addd30b 100644
--- a/doc/src/sgml/ref/pg_resetwal.sgml
+++ b/doc/src/sgml/ref/pg_resetwal.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/pg_resetwal.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-PGRESETWAL">
+<refentry id="app-pgresetwal">
  <indexterm zone="app-pgresetwal">
   <primary>pg_resetwal</primary>
  </indexterm>
@@ -29,7 +29,7 @@ PostgreSQL documentation
   </cmdsynopsis>
  </refsynopsisdiv>
 
- <refsect1 id="R1-APP-PGRESETWAL-1">
+ <refsect1 id="r1-app-pgresetwal-1">
   <title>Description</title>
   <para>
    <command>pg_resetwal</command> clears the write-ahead log (WAL) and
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index ed535f6f89a..2b0a3340257 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/ref/pg_restore.sgml -->
 
-<refentry id="APP-PGRESTORE">
+<refentry id="app-pgrestore">
  <indexterm zone="app-pgrestore">
   <primary>pg_restore</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/pg_waldump.sgml b/doc/src/sgml/ref/pg_waldump.sgml
index 0b39726e30c..40049c51e54 100644
--- a/doc/src/sgml/ref/pg_waldump.sgml
+++ b/doc/src/sgml/ref/pg_waldump.sgml
@@ -29,7 +29,7 @@ PostgreSQL documentation
   </cmdsynopsis>
  </refsynopsisdiv>
 
- <refsect1 id="R1-APP-PGWALDUMP-1">
+ <refsect1 id="r1-app-pgwaldump-1">
   <title>Description</title>
   <para>
    <command>pg_waldump</command> displays the write-ahead log (WAL) and is mainly
diff --git a/doc/src/sgml/ref/prepare.sgml b/doc/src/sgml/ref/prepare.sgml
index bcf188f4b94..fb91ef8d50f 100644
--- a/doc/src/sgml/ref/prepare.sgml
+++ b/doc/src/sgml/ref/prepare.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/prepare.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-PREPARE">
+<refentry id="sql-prepare">
  <indexterm zone="sql-prepare">
   <primary>PREPARE</primary>
  </indexterm>
@@ -123,7 +123,7 @@ PREPARE <replaceable class="parameter">name</replaceable> [ ( <replaceable class
   </variablelist>
  </refsect1>
 
- <refsect1 id="SQL-PREPARE-notes">
+ <refsect1 id="sql-prepare-notes">
   <title>Notes</title>
 
   <para>
diff --git a/doc/src/sgml/ref/prepare_transaction.sgml b/doc/src/sgml/ref/prepare_transaction.sgml
index 4f78e6b1313..6a1766ed3cb 100644
--- a/doc/src/sgml/ref/prepare_transaction.sgml
+++ b/doc/src/sgml/ref/prepare_transaction.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/prepare_transaction.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-PREPARE-TRANSACTION">
+<refentry id="sql-prepare-transaction">
  <indexterm zone="sql-prepare-transaction">
   <primary>PREPARE TRANSACTION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 8cbe0569cf4..e520cdf3ba1 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/psql-ref.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-PSQL">
+<refentry id="app-psql">
  <indexterm zone="app-psql">
   <primary>psql</primary>
  </indexterm>
@@ -45,7 +45,7 @@ PostgreSQL documentation
     </para>
  </refsect1>
 
- <refsect1 id="R1-APP-PSQL-3">
+ <refsect1 id="r1-app-psql-3">
   <title>Options</title>
 
   <variablelist>
@@ -629,7 +629,7 @@ EOF
  <refsect1>
   <title>Usage</title>
 
-  <refsect2 id="R2-APP-PSQL-connecting">
+  <refsect2 id="r2-app-psql-connecting">
     <title>Connecting to a Database</title>
 
     <para>
@@ -701,7 +701,7 @@ $ <userinput>psql postgresql://dbmaster:5433/mydb?sslmode=require</userinput>
     </para>
   </refsect2>
 
-  <refsect2 id="R2-APP-PSQL-4">
+  <refsect2 id="r2-app-psql-4">
     <title>Entering SQL Commands</title>
 
     <para>
@@ -730,8 +730,8 @@ testdb=&gt;
     <para>
     Whenever a command is executed, <application>psql</application> also polls
     for asynchronous notification events generated by
-    <xref linkend="SQL-LISTEN"> and
-    <xref linkend="SQL-NOTIFY">.
+    <xref linkend="sql-listen"> and
+    <xref linkend="sql-notify">.
     </para>
 
     <para>
@@ -741,7 +741,7 @@ testdb=&gt;
     </para>
   </refsect2>
 
-  <refsect2 id="APP-PSQL-meta-commands">
+  <refsect2 id="app-psql-meta-commands">
     <title>Meta-Commands</title>
 
     <para>
@@ -779,7 +779,7 @@ testdb=&gt;
     If an unquoted colon (<literal>:</literal>) followed by a
     <application>psql</application> variable name appears within an argument, it is
     replaced by the variable's value, as described in <xref
-    linkend="APP-PSQL-interpolation" endterm="APP-PSQL-interpolation-title">.
+    linkend="app-psql-interpolation" endterm="app-psql-interpolation-title">.
     The forms <literal>:'<replaceable>variable_name</replaceable>'</literal> and
     <literal>:"<replaceable>variable_name</replaceable>"</literal> described there
     work as well.
@@ -949,7 +949,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry id="APP-PSQL-meta-commands-copy">
+      <varlistentry id="app-psql-meta-commands-copy">
         <term><literal>\copy { <replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column_list</replaceable> ) ] | ( <replaceable class="parameter">query</replaceable> ) }
         { <literal>from</literal> | <literal>to</literal> }
         { <replaceable class="parameter">'filename'</replaceable> | program <replaceable class="parameter">'command'</replaceable> | stdin | stdout | pstdin | pstdout }
@@ -958,7 +958,7 @@ testdb=&gt;
         <listitem>
         <para>
         Performs a frontend (client) copy. This is an operation that
-        runs an <acronym>SQL</acronym> <xref linkend="SQL-COPY">
+        runs an <acronym>SQL</acronym> <xref linkend="sql-copy">
         command, but instead of the server
         reading or writing the specified file,
         <application>psql</application> reads or writes the file and
@@ -1028,7 +1028,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry id="APP-PSQL-meta-commands-crosstabview">
+      <varlistentry id="app-psql-meta-commands-crosstabview">
         <term><literal>\crosstabview [
             <replaceable class="parameter">colV</replaceable>
             [ <replaceable class="parameter">colH</replaceable>
@@ -1102,7 +1102,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\d[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\d[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1116,7 +1116,7 @@ testdb=&gt;
         also shown.  For foreign tables, the associated foreign
         server is shown as well.
         (<quote>Matching the pattern</quote> is defined in
-        <xref linkend="APP-PSQL-patterns" endterm="APP-PSQL-patterns-title">
+        <xref linkend="app-psql-patterns" endterm="app-psql-patterns-title">
         below.)
         </para>
 
@@ -1131,7 +1131,7 @@ testdb=&gt;
         more information is displayed: any comments associated with the
         columns of the table are shown, as is the presence of OIDs in the
         table, the view definition if the relation is a view, a non-default
-        <link linkend="SQL-CREATETABLE-REPLICA-IDENTITY">replica
+        <link linkend="sql-createtable-replica-identity">replica
         identity</link> setting.
         </para>
 
@@ -1155,7 +1155,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\da[S] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\da[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1171,7 +1171,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dA[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dA[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1185,7 +1185,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\db[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\db[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1201,7 +1201,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dc[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dc[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists conversions between character-set encodings.
@@ -1219,7 +1219,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dC[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dC[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists type casts.
@@ -1234,7 +1234,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dd[S] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dd[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Shows the descriptions of objects of type <literal>constraint</literal>,
@@ -1263,7 +1263,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dD[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dD[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists domains. If <replaceable
@@ -1280,7 +1280,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\ddp [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\ddp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists default access privilege settings.  An entry is shown for
@@ -1302,12 +1302,12 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dE[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
-        <term><literal>\di[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
-        <term><literal>\dm[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
-        <term><literal>\ds[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
-        <term><literal>\dt[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
-        <term><literal>\dv[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dE[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\di[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dm[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\ds[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dt[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dv[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1333,7 +1333,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\des[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\des[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign servers (mnemonic: <quote>external
@@ -1349,7 +1349,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\det[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\det[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign tables (mnemonic: <quote>external tables</quote>).
@@ -1364,7 +1364,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\deu[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\deu[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists user mappings (mnemonic: <quote>external
@@ -1387,7 +1387,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dew[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dew[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign-data wrappers (mnemonic: <quote>external
@@ -1403,7 +1403,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\df[antwS+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\df[antwS+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1437,7 +1437,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dF[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dF[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search configurations.
@@ -1451,7 +1451,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dFd[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dFd[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search dictionaries.
@@ -1465,7 +1465,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dFp[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dFp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search parsers.
@@ -1479,7 +1479,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dFt[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dFt[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search templates.
@@ -1493,7 +1493,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dg[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dg[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists database roles.
@@ -1523,7 +1523,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dL[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dL[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists procedural languages. If <replaceable
@@ -1540,7 +1540,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dn[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dn[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1557,7 +1557,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\do[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\do[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists operators with their operand and result types.
@@ -1575,7 +1575,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dO[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dO[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists collations.
@@ -1595,7 +1595,7 @@ testdb=&gt;
 
 
       <varlistentry>
-        <term><literal>\dp [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists tables, views and sequences with their
@@ -1616,7 +1616,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\drds [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">role-pattern</replaceable></link> [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">database-pattern</replaceable></link> ] ]</literal></term>
+        <term><literal>\drds [ <link linkend="app-psql-patterns"><replaceable class="parameter">role-pattern</replaceable></link> [ <link linkend="app-psql-patterns"><replaceable class="parameter">database-pattern</replaceable></link> ] ]</literal></term>
         <listitem>
         <para>
         Lists defined configuration settings.  These settings can be
@@ -1638,7 +1638,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dRp[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dRp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists replication publications.
@@ -1652,7 +1652,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dRs[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dRs[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists replication subscriptions.
@@ -1666,7 +1666,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dT[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dT[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists data types.
@@ -1683,7 +1683,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\du[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\du[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists database roles.
@@ -1702,7 +1702,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dx[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dx[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists installed extensions.
@@ -1716,7 +1716,7 @@ testdb=&gt;
       </varlistentry>
 
       <varlistentry>
-        <term><literal>\dy[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\dy[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists event triggers.
@@ -2027,7 +2027,7 @@ CREATE INDEX
         <para>
          Sends the current query buffer to the server and stores the
          query's output into <application>psql</application> variables (see <xref
-         linkend="APP-PSQL-variables" endterm="APP-PSQL-variables-title">).
+         linkend="app-psql-variables" endterm="app-psql-variables-title">).
          The query to be executed must return exactly one row.  Each column of
          the row is stored into a separate variable, named the same as the
          column.  For example:
@@ -2253,7 +2253,7 @@ SELECT
 
 
       <varlistentry>
-        <term><literal>\l[+]</literal> or <literal>\list[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\l[+]</literal> or <literal>\list[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         List the databases in the server and show their names, owners,
@@ -2831,8 +2831,8 @@ lo_import 152801
 
         <para>
         Illustrations of how these different formats look can be seen in
-        the <xref linkend="APP-PSQL-examples"
-        endterm="APP-PSQL-examples-title"> section.
+        the <xref linkend="app-psql-examples"
+        endterm="app-psql-examples-title"> section.
         </para>
 
         <tip>
@@ -2917,8 +2917,8 @@ lo_import 152801
         <para>
         Valid variable names can contain letters, digits, and
         underscores. See the section <xref
-        linkend="APP-PSQL-variables"
-        endterm="APP-PSQL-variables-title"> below for details.
+        linkend="app-psql-variables"
+        endterm="app-psql-variables-title"> below for details.
         Variable names are case-sensitive.
         </para>
 
@@ -2926,14 +2926,14 @@ lo_import 152801
         Certain variables are special, in that they
         control <application>psql</application>'s behavior or are
         automatically set to reflect connection state.  These variables are
-        documented in <xref linkend="APP-PSQL-variables"
-        endterm="APP-PSQL-variables-title">, below.
+        documented in <xref linkend="app-psql-variables"
+        endterm="app-psql-variables-title">, below.
         </para>
 
         <note>
         <para>
         This command is unrelated to the <acronym>SQL</acronym>
-        command <xref linkend="SQL-SET">.
+        command <xref linkend="sql-set">.
         </para>
         </note>
         </listitem>
@@ -3070,8 +3070,8 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
         Most variables that control <application>psql</application>'s behavior
         cannot be unset; instead, an <literal>\unset</literal> command is interpreted
         as setting them to their default values.
-        See <xref linkend="APP-PSQL-variables"
-        endterm="APP-PSQL-variables-title">, below.
+        See <xref linkend="app-psql-variables"
+        endterm="app-psql-variables-title">, below.
         </para>
         </listitem>
       </varlistentry>
@@ -3131,7 +3131,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
 
 
       <varlistentry>
-        <term><literal>\z [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\z [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists tables, views and sequences with their
@@ -3229,8 +3229,8 @@ select 1\; select 2\; select 3;
     </variablelist>
   </para>
 
-  <refsect3 id="APP-PSQL-patterns">
-   <title id="APP-PSQL-patterns-title">Patterns</title>
+  <refsect3 id="app-psql-patterns">
+   <title id="app-psql-patterns-title">Patterns</title>
 
    <indexterm>
     <primary>patterns</primary>
@@ -3322,8 +3322,8 @@ select 1\; select 2\; select 3;
  <refsect2>
   <title>Advanced Features</title>
 
-   <refsect3 id="APP-PSQL-variables">
-    <title id="APP-PSQL-variables-title">Variables</title>
+   <refsect3 id="app-psql-variables">
+    <title id="app-psql-variables-title">Variables</title>
 
     <para>
     <application>psql</application> provides variable substitution
@@ -3347,8 +3347,8 @@ testdb=&gt; <userinput>\echo :foo</userinput>
 bar
 </programlisting>
     This works in both regular SQL commands and meta-commands; there is
-    more detail in <xref linkend="APP-PSQL-interpolation"
-    endterm="APP-PSQL-interpolation-title">, below.
+    more detail in <xref linkend="app-psql-interpolation"
+    endterm="app-psql-interpolation-title">, below.
     </para>
 
     <para>
@@ -3742,8 +3742,8 @@ bar
         <para>
         These specify what the prompts <application>psql</application>
         issues should look like. See <xref
-        linkend="APP-PSQL-prompting"
-        endterm="APP-PSQL-prompting-title"> below.
+        linkend="app-psql-prompting"
+        endterm="app-psql-prompting-title"> below.
         </para>
         </listitem>
       </varlistentry>
@@ -3875,8 +3875,8 @@ bar
 
    </refsect3>
 
-   <refsect3 id="APP-PSQL-interpolation">
-    <title id="APP-PSQL-interpolation-title"><acronym>SQL</acronym> Interpolation</title>
+   <refsect3 id="app-psql-interpolation">
+    <title id="app-psql-interpolation-title"><acronym>SQL</acronym> Interpolation</title>
 
     <para>
     A key feature of <application>psql</application>
@@ -3960,8 +3960,8 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
 
    </refsect3>
 
-   <refsect3 id="APP-PSQL-prompting">
-    <title id="APP-PSQL-prompting-title">Prompting</title>
+   <refsect3 id="app-psql-prompting">
+    <title id="app-psql-prompting-title">Prompting</title>
 
     <para>
     The prompts <application>psql</application> issues can be customized
@@ -4118,8 +4118,8 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         <para>
         The value of the <application>psql</application> variable
         <replaceable class="parameter">name</replaceable>. See the
-        section <xref linkend="APP-PSQL-variables"
-        endterm="APP-PSQL-variables-title"> for details.
+        section <xref linkend="app-psql-variables"
+        endterm="app-psql-variables-title"> for details.
         </para>
         </listitem>
       </varlistentry>
@@ -4499,8 +4499,8 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
  </refsect1>
 
 
- <refsect1 id="APP-PSQL-examples">
-  <title id="APP-PSQL-examples-title">Examples</title>
+ <refsect1 id="app-psql-examples">
+  <title id="app-psql-examples-title">Examples</title>
 
   <para>
   The first example shows how to spread a command over several lines of
diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml
index 2bbd6b8f07a..e29b88292be 100644
--- a/doc/src/sgml/ref/reassign_owned.sgml
+++ b/doc/src/sgml/ref/reassign_owned.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/reassign_owned.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-REASSIGN-OWNED">
+<refentry id="sql-reassign-owned">
  <indexterm zone="sql-reassign-owned">
   <primary>REASSIGN OWNED</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/refresh_materialized_view.sgml b/doc/src/sgml/ref/refresh_materialized_view.sgml
index 0135d15cece..e2ee836efb9 100644
--- a/doc/src/sgml/ref/refresh_materialized_view.sgml
+++ b/doc/src/sgml/ref/refresh_materialized_view.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/refresh_materialized_view.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-REFRESHMATERIALIZEDVIEW">
+<refentry id="sql-refreshmaterializedview">
  <indexterm zone="sql-refreshmaterializedview">
   <primary>REFRESH MATERIALIZED VIEW</primary>
  </indexterm>
@@ -93,7 +93,7 @@ REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] <replaceable class="parameter">name</
 
   <para>
    While the default index for future
-   <xref linkend="SQL-CLUSTER">
+   <xref linkend="sql-cluster">
    operations is retained, <command>REFRESH MATERIALIZED VIEW</command> does not
    order the generated rows based on this property. If you want the data
    to be ordered upon generation, you must use an <literal>ORDER BY</literal>
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index 3dc2608f76e..2e053c4c24d 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/reindex.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-REINDEX">
+<refentry id="sql-reindex">
  <indexterm zone="sql-reindex">
   <primary>REINDEX</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/reindexdb.sgml b/doc/src/sgml/ref/reindexdb.sgml
index 627be6a0add..a7cc9c2d946 100644
--- a/doc/src/sgml/ref/reindexdb.sgml
+++ b/doc/src/sgml/ref/reindexdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/reindexdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-REINDEXDB">
+<refentry id="app-reindexdb">
  <indexterm zone="app-reindexdb">
   <primary>reindexdb</primary>
  </indexterm>
@@ -93,7 +93,7 @@ PostgreSQL documentation
 
   <para>
    <application>reindexdb</application> is a wrapper around the SQL
-   command <xref linkend="SQL-REINDEX">.
+   command <xref linkend="sql-reindex">.
    There is no effective difference between reindexing databases via
    this utility and via other methods for accessing the server.
   </para>
@@ -357,8 +357,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-REINDEX">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-reindex">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/release_savepoint.sgml b/doc/src/sgml/ref/release_savepoint.sgml
index 2e8dcc0746e..7e629176b71 100644
--- a/doc/src/sgml/ref/release_savepoint.sgml
+++ b/doc/src/sgml/ref/release_savepoint.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/release_savepoint.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-RELEASE-SAVEPOINT">
+<refentry id="sql-release-savepoint">
  <indexterm zone="sql-release-savepoint">
   <primary>RELEASE SAVEPOINT</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/reset.sgml b/doc/src/sgml/ref/reset.sgml
index b434ad10c28..bf3f5226ec2 100644
--- a/doc/src/sgml/ref/reset.sgml
+++ b/doc/src/sgml/ref/reset.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/reset.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-RESET">
+<refentry id="sql-reset">
  <indexterm zone="sql-reset">
   <primary>RESET</primary>
  </indexterm>
@@ -106,8 +106,8 @@ RESET timezone;
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="SQL-SET"></member>
-   <member><xref linkend="SQL-SHOW"></member>
+   <member><xref linkend="sql-set"></member>
+   <member><xref linkend="sql-show"></member>
   </simplelist>
  </refsect1>
 </refentry>
diff --git a/doc/src/sgml/ref/revoke.sgml b/doc/src/sgml/ref/revoke.sgml
index c893666e83a..e3e3f2ffc3f 100644
--- a/doc/src/sgml/ref/revoke.sgml
+++ b/doc/src/sgml/ref/revoke.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/revoke.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-REVOKE">
+<refentry id="sql-revoke">
  <indexterm zone="sql-revoke">
   <primary>REVOKE</primary>
  </indexterm>
@@ -111,7 +111,7 @@ REVOKE [ ADMIN OPTION FOR ]
 </synopsis>
  </refsynopsisdiv>
 
- <refsect1 id="SQL-REVOKE-description">
+ <refsect1 id="sql-revoke-description">
   <title>Description</title>
 
   <para>
@@ -174,7 +174,7 @@ REVOKE [ ADMIN OPTION FOR ]
   </para>
  </refsect1>
 
- <refsect1 id="SQL-REVOKE-notes">
+ <refsect1 id="sql-revoke-notes">
   <title>Notes</title>
 
   <para>
@@ -246,7 +246,7 @@ REVOKE [ ADMIN OPTION FOR ]
    </para>
  </refsect1>
 
- <refsect1 id="SQL-REVOKE-examples">
+ <refsect1 id="sql-revoke-examples">
   <title>Examples</title>
 
   <para>
@@ -278,7 +278,7 @@ REVOKE admins FROM joe;
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="SQL-REVOKE-compatibility">
+ <refsect1 id="sql-revoke-compatibility">
   <title>Compatibility</title>
 
    <para>
diff --git a/doc/src/sgml/ref/rollback.sgml b/doc/src/sgml/ref/rollback.sgml
index 1a0e5a0ebcf..1f99343b08d 100644
--- a/doc/src/sgml/ref/rollback.sgml
+++ b/doc/src/sgml/ref/rollback.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/rollback.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ROLLBACK">
+<refentry id="sql-rollback">
  <indexterm zone="sql-rollback">
   <primary>ROLLBACK</primary>
  </indexterm>
@@ -54,7 +54,7 @@ ROLLBACK [ WORK | TRANSACTION ]
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-COMMIT"> to
+   Use <xref linkend="sql-commit"> to
    successfully terminate a transaction.
   </para>
 
diff --git a/doc/src/sgml/ref/rollback_prepared.sgml b/doc/src/sgml/ref/rollback_prepared.sgml
index 6c44049a898..d7468f78d72 100644
--- a/doc/src/sgml/ref/rollback_prepared.sgml
+++ b/doc/src/sgml/ref/rollback_prepared.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/rollback_prepared.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ROLLBACK-PREPARED">
+<refentry id="sql-rollback-prepared">
  <indexterm zone="sql-rollback-prepared">
   <primary>ROLLBACK PREPARED</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/rollback_to.sgml b/doc/src/sgml/ref/rollback_to.sgml
index f1da804f67f..1957cace117 100644
--- a/doc/src/sgml/ref/rollback_to.sgml
+++ b/doc/src/sgml/ref/rollback_to.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/rollback_to.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-ROLLBACK-TO">
+<refentry id="sql-rollback-to">
  <indexterm zone="sql-rollback-to">
   <primary>ROLLBACK TO SAVEPOINT</primary>
  </indexterm>
@@ -64,7 +64,7 @@ ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] <replaceable>savepoint_name</re
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-RELEASE-SAVEPOINT"> to destroy a savepoint
+   Use <xref linkend="sql-release-savepoint"> to destroy a savepoint
    without discarding the effects of commands executed after it was
    established.
   </para>
diff --git a/doc/src/sgml/ref/savepoint.sgml b/doc/src/sgml/ref/savepoint.sgml
index 6d40f4da420..6fa11a7358f 100644
--- a/doc/src/sgml/ref/savepoint.sgml
+++ b/doc/src/sgml/ref/savepoint.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/savepoint.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SAVEPOINT">
+<refentry id="sql-savepoint">
  <indexterm zone="sql-savepoint">
   <primary>SAVEPOINT</primary>
  </indexterm>
@@ -64,8 +64,8 @@ SAVEPOINT <replaceable>savepoint_name</replaceable>
   <title>Notes</title>
 
   <para>
-   Use <xref linkend="SQL-ROLLBACK-TO"> to
-   rollback to a savepoint.  Use <xref linkend="SQL-RELEASE-SAVEPOINT">
+   Use <xref linkend="sql-rollback-to"> to
+   rollback to a savepoint.  Use <xref linkend="sql-release-savepoint">
    to destroy a savepoint, keeping
    the effects of commands executed after it was established.
   </para>
diff --git a/doc/src/sgml/ref/security_label.sgml b/doc/src/sgml/ref/security_label.sgml
index 999f9c80cd5..ce5a1c19754 100644
--- a/doc/src/sgml/ref/security_label.sgml
+++ b/doc/src/sgml/ref/security_label.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/security_label.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SECURITY-LABEL">
+<refentry id="sql-security-label">
  <indexterm zone="sql-security-label">
   <primary>SECURITY LABEL</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml
index 7355e790f69..3aab3fd8a72 100644
--- a/doc/src/sgml/ref/select.sgml
+++ b/doc/src/sgml/ref/select.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/select.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SELECT">
+<refentry id="sql-select">
  <indexterm zone="sql-select">
   <primary>SELECT</primary>
  </indexterm>
@@ -218,7 +218,7 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
  <refsect1>
   <title>Parameters</title>
 
-  <refsect2 id="SQL-WITH">
+  <refsect2 id="sql-with">
    <title id="sql-with-title"><literal>WITH</literal> Clause</title>
 
    <para>
@@ -295,7 +295,7 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-FROM">
+  <refsect2 id="sql-from">
    <title id="sql-from-title"><literal>FROM</literal> Clause</title>
 
    <para>
@@ -666,7 +666,7 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-WHERE">
+  <refsect2 id="sql-where">
    <title id="sql-where-title"><literal>WHERE</literal> Clause</title>
 
    <para>
@@ -683,7 +683,7 @@ WHERE <replaceable class="parameter">condition</replaceable>
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-GROUPBY">
+  <refsect2 id="sql-groupby">
    <title id="sql-groupby-title"><literal>GROUP BY</literal> Clause</title>
 
    <para>
@@ -757,7 +757,7 @@ GROUP BY <replaceable class="parameter">grouping_element</replaceable> [, ...]
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-HAVING">
+  <refsect2 id="sql-having">
    <title id="sql-having-title"><literal>HAVING</literal> Clause</title>
 
    <para>
@@ -800,7 +800,7 @@ HAVING <replaceable class="parameter">condition</replaceable>
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-WINDOW">
+  <refsect2 id="sql-window">
    <title id="sql-window-title"><literal>WINDOW</literal> Clause</title>
 
    <para>
@@ -1073,7 +1073,7 @@ SELECT DISTINCT ON (location) location, time, report
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-UNION">
+  <refsect2 id="sql-union">
    <title id="sql-union-title"><literal>UNION</literal> Clause</title>
 
    <para>
@@ -1126,7 +1126,7 @@ SELECT DISTINCT ON (location) location, time, report
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-INTERSECT">
+  <refsect2 id="sql-intersect">
    <title id="sql-intersect-title"><literal>INTERSECT</literal> Clause</title>
 
    <para>
@@ -1174,7 +1174,7 @@ SELECT DISTINCT ON (location) location, time, report
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-EXCEPT">
+  <refsect2 id="sql-except">
    <title id="sql-except-title"><literal>EXCEPT</literal> Clause</title>
 
    <para>
@@ -1218,7 +1218,7 @@ SELECT DISTINCT ON (location) location, time, report
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-ORDERBY">
+  <refsect2 id="sql-orderby">
    <title id="sql-orderby-title"><literal>ORDER BY</literal> Clause</title>
 
    <para>
@@ -1316,7 +1316,7 @@ SELECT name FROM distributors ORDER BY code;
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-LIMIT">
+  <refsect2 id="sql-limit">
    <title id="sql-limit-title"><literal>LIMIT</literal> Clause</title>
 
    <para>
@@ -1396,7 +1396,7 @@ FETCH { FIRST | NEXT } [ <replaceable class="parameter">count</replaceable> ] {
    </para>
   </refsect2>
 
-  <refsect2 id="SQL-FOR-UPDATE-SHARE">
+  <refsect2 id="sql-for-update-share">
    <title id="sql-for-update-share-title">The Locking Clause</title>
 
    <para>
@@ -1560,7 +1560,7 @@ SELECT * FROM (SELECT * FROM mytable FOR UPDATE) ss ORDER BY column1;
   </caution>
   </refsect2>
 
-  <refsect2 id="SQL-TABLE">
+  <refsect2 id="sql-table">
    <title><literal>TABLE</literal> Command</title>
 
    <para>
diff --git a/doc/src/sgml/ref/select_into.sgml b/doc/src/sgml/ref/select_into.sgml
index 63c02349aa4..a5b6ac9245a 100644
--- a/doc/src/sgml/ref/select_into.sgml
+++ b/doc/src/sgml/ref/select_into.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/select_into.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SELECTINTO">
+<refentry id="sql-selectinto">
  <indexterm zone="sql-selectinto">
   <primary>SELECT INTO</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/set.sgml b/doc/src/sgml/ref/set.sgml
index 8c44d0e156d..4bc8108765c 100644
--- a/doc/src/sgml/ref/set.sgml
+++ b/doc/src/sgml/ref/set.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/set.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SET">
+<refentry id="sql-set">
  <indexterm zone="sql-set">
   <primary>SET</primary>
  </indexterm>
@@ -323,8 +323,8 @@ SET TIME ZONE 'Europe/Rome';
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="SQL-RESET"></member>
-   <member><xref linkend="SQL-SHOW"></member>
+   <member><xref linkend="sql-reset"></member>
+   <member><xref linkend="sql-show"></member>
   </simplelist>
  </refsect1>
 </refentry>
diff --git a/doc/src/sgml/ref/set_constraints.sgml b/doc/src/sgml/ref/set_constraints.sgml
index 237a0a3988f..671332afc7a 100644
--- a/doc/src/sgml/ref/set_constraints.sgml
+++ b/doc/src/sgml/ref/set_constraints.sgml
@@ -1,5 +1,5 @@
 <!-- doc/src/sgml/ref/set_constraints.sgml -->
-<refentry id="SQL-SET-CONSTRAINTS">
+<refentry id="sql-set-constraints">
  <indexterm zone="sql-set-constraints">
   <primary>SET CONSTRAINTS</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/set_role.sgml b/doc/src/sgml/ref/set_role.sgml
index eac4b3405ae..351e953f757 100644
--- a/doc/src/sgml/ref/set_role.sgml
+++ b/doc/src/sgml/ref/set_role.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/set_role.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SET-ROLE">
+<refentry id="sql-set-role">
  <indexterm zone="sql-set-role">
   <primary>SET ROLE</primary>
  </indexterm>
@@ -48,7 +48,7 @@ RESET ROLE
 
   <para>
    The <literal>SESSION</literal> and <literal>LOCAL</literal> modifiers act the same
-   as for the regular <xref linkend="SQL-SET">
+   as for the regular <xref linkend="sql-set">
    command.
   </para>
 
diff --git a/doc/src/sgml/ref/set_session_auth.sgml b/doc/src/sgml/ref/set_session_auth.sgml
index a8aee6f6323..45fa378e188 100644
--- a/doc/src/sgml/ref/set_session_auth.sgml
+++ b/doc/src/sgml/ref/set_session_auth.sgml
@@ -1,5 +1,5 @@
 <!-- doc/src/sgml/ref/set_session_auth.sgml -->
-<refentry id="SQL-SET-SESSION-AUTHORIZATION">
+<refentry id="sql-set-session-authorization">
  <indexterm zone="sql-set-session-authorization">
   <primary>SET SESSION AUTHORIZATION</primary>
  </indexterm>
@@ -54,7 +54,7 @@ RESET SESSION AUTHORIZATION
 
   <para>
    The <literal>SESSION</literal> and <literal>LOCAL</literal> modifiers act the same
-   as for the regular <xref linkend="SQL-SET">
+   as for the regular <xref linkend="sql-set">
    command.
   </para>
 
diff --git a/doc/src/sgml/ref/set_transaction.sgml b/doc/src/sgml/ref/set_transaction.sgml
index f5631372f56..3ab1e6f7719 100644
--- a/doc/src/sgml/ref/set_transaction.sgml
+++ b/doc/src/sgml/ref/set_transaction.sgml
@@ -1,5 +1,5 @@
 <!-- doc/src/sgml/ref/set_transaction.sgml -->
-<refentry id="SQL-SET-TRANSACTION">
+<refentry id="sql-set-transaction">
  <indexterm zone="sql-set-transaction">
   <primary>SET TRANSACTION</primary>
  </indexterm>
@@ -237,7 +237,7 @@ SET TRANSACTION SNAPSHOT '00000003-0000001B-1';
 </programlisting></para>
  </refsect1>
 
- <refsect1 id="R1-SQL-SET-TRANSACTION-3">
+ <refsect1 id="r1-sql-set-transaction-3">
   <title>Compatibility</title>
 
   <para>
diff --git a/doc/src/sgml/ref/show.sgml b/doc/src/sgml/ref/show.sgml
index 2a2b2fbb9f3..53b47ac3d8f 100644
--- a/doc/src/sgml/ref/show.sgml
+++ b/doc/src/sgml/ref/show.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/show.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-SHOW">
+<refentry id="sql-show">
  <indexterm zone="sql-show">
   <primary>SHOW</primary>
  </indexterm>
@@ -52,7 +52,7 @@ SHOW ALL
      <para>
       The name of a run-time parameter.  Available parameters are
       documented in <xref linkend="runtime-config"> and on the <xref
-      linkend="SQL-SET"> reference page.  In
+      linkend="sql-set"> reference page.  In
       addition, there are a few parameters that can be shown but not
       set:
 
@@ -192,8 +192,8 @@ SHOW ALL;
   <title>See Also</title>
 
   <simplelist type="inline">
-   <member><xref linkend="SQL-SET"></member>
-   <member><xref linkend="SQL-RESET"></member>
+   <member><xref linkend="sql-set"></member>
+   <member><xref linkend="sql-reset"></member>
   </simplelist>
  </refsect1>
 
diff --git a/doc/src/sgml/ref/start_transaction.sgml b/doc/src/sgml/ref/start_transaction.sgml
index 8dcf6318d23..605fda53575 100644
--- a/doc/src/sgml/ref/start_transaction.sgml
+++ b/doc/src/sgml/ref/start_transaction.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/start_transaction.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-START-TRANSACTION">
+<refentry id="sql-start-transaction">
  <indexterm zone="sql-start-transaction">
   <primary>START TRANSACTION</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/truncate.sgml b/doc/src/sgml/ref/truncate.sgml
index 80abe675253..68925169879 100644
--- a/doc/src/sgml/ref/truncate.sgml
+++ b/doc/src/sgml/ref/truncate.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/truncate.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-TRUNCATE">
+<refentry id="sql-truncate">
  <indexterm zone="sql-truncate">
   <primary>TRUNCATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/unlisten.sgml b/doc/src/sgml/ref/unlisten.sgml
index 1ea9aa3a0bd..1bffac3cb2c 100644
--- a/doc/src/sgml/ref/unlisten.sgml
+++ b/doc/src/sgml/ref/unlisten.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/unlisten.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-UNLISTEN">
+<refentry id="sql-unlisten">
  <indexterm zone="sql-unlisten">
   <primary>UNLISTEN</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml
index 1ede52384f3..0e99aa97398 100644
--- a/doc/src/sgml/ref/update.sgml
+++ b/doc/src/sgml/ref/update.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/update.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-UPDATE">
+<refentry id="sql-update">
  <indexterm zone="sql-update">
   <primary>UPDATE</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/vacuum.sgml b/doc/src/sgml/ref/vacuum.sgml
index 2e205668c1c..7ecd08977c5 100644
--- a/doc/src/sgml/ref/vacuum.sgml
+++ b/doc/src/sgml/ref/vacuum.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/vacuum.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-VACUUM">
+<refentry id="sql-vacuum">
  <indexterm zone="sql-vacuum">
   <primary>VACUUM</primary>
  </indexterm>
diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml
index 277c231687b..2d47d8c1f11 100644
--- a/doc/src/sgml/ref/vacuumdb.sgml
+++ b/doc/src/sgml/ref/vacuumdb.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/vacuumdb.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="APP-VACUUMDB">
+<refentry id="app-vacuumdb">
  <indexterm zone="app-vacuumdb">
   <primary>vacuumdb</primary>
  </indexterm>
@@ -62,7 +62,7 @@ PostgreSQL documentation
 
   <para>
    <application>vacuumdb</application> is a wrapper around the SQL
-   command <xref linkend="SQL-VACUUM">.
+   command <xref linkend="sql-vacuum">.
    There is no effective difference between vacuuming and analyzing
    databases via this utility and via other methods for accessing the
    server.
@@ -382,8 +382,8 @@ PostgreSQL documentation
   <title>Diagnostics</title>
 
   <para>
-   In case of difficulty, see <xref linkend="SQL-VACUUM">
-   and <xref linkend="APP-PSQL"> for
+   In case of difficulty, see <xref linkend="sql-vacuum">
+   and <xref linkend="app-psql"> for
    discussions of potential problems and error messages.
    The database server must be running at the
    targeted host.  Also, any default connection settings and environment
diff --git a/doc/src/sgml/ref/values.sgml b/doc/src/sgml/ref/values.sgml
index 75a594725b8..6b8083fc9d3 100644
--- a/doc/src/sgml/ref/values.sgml
+++ b/doc/src/sgml/ref/values.sgml
@@ -3,7 +3,7 @@ doc/src/sgml/ref/values.sgml
 PostgreSQL documentation
 -->
 
-<refentry id="SQL-VALUES">
+<refentry id="sql-values">
  <indexterm zone="sql-values">
   <primary>VALUES</primary>
  </indexterm>
diff --git a/doc/src/sgml/release-10.sgml b/doc/src/sgml/release-10.sgml
index 98149db3352..d37f700055c 100644
--- a/doc/src/sgml/release-10.sgml
+++ b/doc/src/sgml/release-10.sgml
@@ -701,7 +701,7 @@
        </para>
 
        <para>
-        A new <link linkend="SQL-CREATEINDEX"><command>CREATE
+        A new <link linkend="sql-createindex"><command>CREATE
         INDEX</command></link> option enables auto-summarization of the
         previous <acronym>BRIN</acronym> page range when a new page
         range is created.
@@ -825,9 +825,9 @@
 
       <para>
        New commands are <link
-       linkend="SQL-CREATESTATISTICS"><command>CREATE STATISTICS</command></link>,
-       <link linkend="SQL-ALTERSTATISTICS"><command>ALTER STATISTICS</command></link>, and
-       <link linkend="SQL-DROPSTATISTICS"><command>DROP STATISTICS</command></link>.
+       linkend="sql-createstatistics"><command>CREATE STATISTICS</command></link>,
+       <link linkend="sql-alterstatistics"><command>ALTER STATISTICS</command></link>, and
+       <link linkend="sql-dropstatistics"><command>DROP STATISTICS</command></link>.
        This feature is helpful in estimating query memory usage and when
        combining the statistics from individual columns.
       </para>
@@ -950,7 +950,7 @@
 -->
        <para>
         Allow explicit control
-        over <link linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link>'s display
+        over <link linkend="sql-explain"><command>EXPLAIN</command></link>'s display
         of planning and execution time (Ashutosh Bapat)
        </para>
 
@@ -983,7 +983,7 @@
 -->
        <para>
         Properly update the statistics collector during <link
-        linkend="SQL-REFRESHMATERIALIZEDVIEW"><command>REFRESH MATERIALIZED
+        linkend="sql-refreshmaterializedview"><command>REFRESH MATERIALIZED
         VIEW</command></link> (Jim Mlodgenski)
        </para>
       </listitem>
@@ -1586,7 +1586,7 @@
 2016-12-07 [f0e44751d] Implement table partitioning.
 -->
       <para>
-       Add table <link linkend="SQL-CREATETABLE-PARTITION">partitioning
+       Add table <link linkend="sql-createtable-partition">partitioning
        syntax</link> that automatically creates partition constraints and
        handles routing of tuple insertions and updates (Amit Langote)
       </para>
@@ -1603,7 +1603,7 @@
 2017-03-31 [597027163] Add transition table support to plpgsql.
 -->
       <para>
-       Add <link linkend="SQL-CREATETRIGGER"><literal>AFTER</literal> trigger</link>
+       Add <link linkend="sql-createtrigger"><literal>AFTER</literal> trigger</link>
        transition tables to record changed rows (Kevin Grittner, Thomas
        Munro)
       </para>
@@ -1619,7 +1619,7 @@
 2016-12-05 [093129c9d] Add support for restrictive RLS policies
 -->
       <para>
-       Allow <link linkend="SQL-CREATEPOLICY">restrictive row-level
+       Allow <link linkend="sql-createpolicy">restrictive row-level
        security policies</link> (Stephen Frost)
       </para>
 
@@ -1655,7 +1655,7 @@
 2017-03-28 [ab89e465c] Altering default privileges on schemas
 -->
       <para>
-       Allow <link linkend="SQL-ALTERDEFAULTPRIVILEGES">default
+       Allow <link linkend="sql-alterdefaultprivileges">default
        permissions</link> on schemas (Matheus Oliveira)
       </para>
 
@@ -1669,7 +1669,7 @@
 2017-02-10 [2ea5b06c7] Add CREATE SEQUENCE AS <data type> clause
 -->
       <para>
-       Add <link linkend="SQL-CREATESEQUENCE"><command>CREATE SEQUENCE
+       Add <link linkend="sql-createsequence"><command>CREATE SEQUENCE
        AS</command></link> command to create a sequence matching an integer data type
        (Peter Eisentraut)
       </para>
@@ -1705,7 +1705,7 @@
       </para>
 
       <para>
-       For example, allow <link linkend="SQL-DROPFUNCTION"><command>DROP
+       For example, allow <link linkend="sql-dropfunction"><command>DROP
        FUNCTION</command></link> on a function name without arguments if there
        is only one function with that name.  This behavior is required by the
        <acronym>SQL</acronym> standard.
@@ -1729,9 +1729,9 @@
 -->
       <para>
        Support <literal>IF NOT EXISTS</literal>
-       in <link linkend="SQL-CREATESERVER"><command>CREATE SERVER</command></link>,
-       <link linkend="SQL-CREATEUSERMAPPING"><command>CREATE USER MAPPING</command></link>,
-       and <link linkend="SQL-CREATECOLLATION"><command>CREATE COLLATION</command></link>
+       in <link linkend="sql-createserver"><command>CREATE SERVER</command></link>,
+       <link linkend="sql-createusermapping"><command>CREATE USER MAPPING</command></link>,
+       and <link linkend="sql-createcollation"><command>CREATE COLLATION</command></link>
        (Anastasia Lubennikova, Peter Eisentraut)
       </para>
      </listitem>
@@ -1742,7 +1742,7 @@
 2017-03-03 [9eb344faf] Allow vacuums to report oldestxmin
 -->
       <para>
-       Make <link linkend="SQL-VACUUM"><command>VACUUM VERBOSE</command></link> report
+       Make <link linkend="sql-vacuum"><command>VACUUM VERBOSE</command></link> report
        the number of skipped frozen pages and oldest xmin (Masahiko
        Sawada, Simon Riggs)
       </para>
@@ -1809,7 +1809,7 @@
 2017-04-06 [321732705] Identity columns
 -->
       <para>
-       Add <link linkend="SQL-CREATETABLE">identity columns</link> for
+       Add <link linkend="sql-createtable">identity columns</link> for
        assigning a numeric value to columns on insert (Peter Eisentraut)
       </para>
 
@@ -1829,7 +1829,7 @@
       </para>
 
       <para>
-       This uses the syntax <link linkend="SQL-ALTERTYPE"><command>ALTER
+       This uses the syntax <link linkend="sql-altertype"><command>ALTER
        TYPE ... RENAME VALUE</command></link>.
       </para>
      </listitem>
@@ -2191,7 +2191,7 @@
     <title>Client Applications</title>
 
     <sect4>
-     <title><xref linkend="APP-PSQL"></title>
+     <title><xref linkend="app-psql"></title>
 
      <itemizedlist>
 
@@ -2414,7 +2414,7 @@
 2016-10-19 [5d58c07a4] initdb pg_basebackup: Rename -\-noxxx options to -\-no-x
 -->
       <para>
-       Rename <link linkend="APP-INITDB"><application>initdb</application></link>
+       Rename <link linkend="app-initdb"><application>initdb</application></link>
        options <option>--noclean</option> and <option>--nosync</option> to be spelled
        <option>--no-clean</option> and <option>--no-sync</option> (Vik Fearing,
        Peter Eisentraut)
@@ -2428,9 +2428,9 @@
     </itemizedlist>
 
     <sect4>
-     <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link>,
-     <link linkend="APP-PG-DUMPALL"><application>pg_dumpall</application></link>,
-     <link linkend="APP-PGRESTORE"><application>pg_restore</application></link></title>
+     <title><link linkend="app-pgdump"><application>pg_dump</application></link>,
+     <link linkend="app-pg-dumpall"><application>pg_dumpall</application></link>,
+     <link linkend="app-pgrestore"><application>pg_restore</application></link></title>
 
      <itemizedlist>
 
diff --git a/doc/src/sgml/release-8.2.sgml b/doc/src/sgml/release-8.2.sgml
index 71b50cfb01d..39666e665be 100644
--- a/doc/src/sgml/release-8.2.sgml
+++ b/doc/src/sgml/release-8.2.sgml
@@ -4718,7 +4718,7 @@
 
      <listitem>
       <para>
-       Make <link linkend="SQL-SET-CONSTRAINTS"><command>SET
+       Make <link linkend="sql-set-constraints"><command>SET
        CONSTRAINT</command></link> affect only one constraint (Kris Jurka)
       </para>
 
@@ -5023,8 +5023,8 @@
      <listitem>
       <para>
        Add <literal>FILLFACTOR</literal> to <link
-       linkend="SQL-CREATETABLE">table</link> and <link
-       linkend="SQL-CREATEINDEX">index</link> creation (ITAGAKI
+       linkend="sql-createtable">table</link> and <link
+       linkend="sql-createindex">index</link> creation (ITAGAKI
        Takahiro)
       </para>
 
@@ -5132,13 +5132,13 @@
      <listitem>
       <para>
        Avoid extra scan of tables without indexes during <link
-       linkend="SQL-VACUUM"><command>VACUUM</command></link> (Greg Stark)
+       linkend="sql-vacuum"><command>VACUUM</command></link> (Greg Stark)
       </para>
      </listitem>
 
      <listitem>
       <para>
-       Improve multicolumn <link linkend="GiST"><acronym>GiST</acronym></link>
+       Improve multicolumn <link linkend="gist"><acronym>GiST</acronym></link>
        indexing (Oleg, Teodor)
       </para>
      </listitem>
@@ -5268,7 +5268,7 @@
 
      <listitem>
       <para>
-       <link linkend="GiST"><acronym>GiST</acronym></link> indexes are
+       <link linkend="gist"><acronym>GiST</acronym></link> indexes are
        now clusterable (Teodor)
       </para>
      </listitem>
@@ -5475,9 +5475,9 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-INSERT"><command>INSERT</command></link>/<link
-       linkend="SQL-UPDATE"><command>UPDATE</command></link>/<link
-       linkend="SQL-DELETE"><command>DELETE</command></link>
+       Add <link linkend="sql-insert"><command>INSERT</command></link>/<link
+       linkend="sql-update"><command>UPDATE</command></link>/<link
+       linkend="sql-delete"><command>DELETE</command></link>
        <literal>RETURNING</literal> (Jonah Harris, Tom)
       </para>
 
@@ -5506,8 +5506,8 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-UPDATE"><command>UPDATE</command></link>
-       and <link linkend="SQL-DELETE"><command>DELETE</command></link>
+       Allow <link linkend="sql-update"><command>UPDATE</command></link>
+       and <link linkend="sql-delete"><command>DELETE</command></link>
        to use an alias for the target table (Atsushi Ogawa)
       </para>
 
@@ -5519,7 +5519,7 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-UPDATE"><command>UPDATE</command></link>
+       Allow <link linkend="sql-update"><command>UPDATE</command></link>
        to set multiple columns with a list of values (Susanne
        Ebrecht)
       </para>
@@ -5546,7 +5546,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-TRUNCATE"><literal>CASCADE</literal></link>
+       Add <link linkend="sql-truncate"><literal>CASCADE</literal></link>
        option to <command>TRUNCATE</command> (Joachim Wieland)
       </para>
 
@@ -5560,7 +5560,7 @@
      <listitem>
       <para>
        Support <literal>FOR UPDATE</literal> and <literal>FOR SHARE</literal>
-       in the same <link linkend="SQL-INSERT"><literal>SELECT</literal></link>
+       in the same <link linkend="sql-insert"><literal>SELECT</literal></link>
        command (Tom)
       </para>
      </listitem>
@@ -5652,8 +5652,8 @@
      <listitem>
       <para>
        Support portal parameters in <link
-       linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link> and <link
-       linkend="SQL-EXECUTE"><command>EXECUTE</command></link> (Tom)
+       linkend="sql-explain"><command>EXPLAIN</command></link> and <link
+       linkend="sql-execute"><command>EXECUTE</command></link> (Tom)
       </para>
 
       <para>
@@ -5665,7 +5665,7 @@
      <listitem>
       <para>
        If <acronym>SQL</acronym>-level <link
-       linkend="SQL-PREPARE"><command>PREPARE</command></link> parameters
+       linkend="sql-prepare"><command>PREPARE</command></link> parameters
        are unspecified, infer their types from the content of the
        query (Neil)
       </para>
@@ -5693,7 +5693,7 @@
      <listitem>
       <para>
        Add <literal>TABLESPACE</literal> clause to <link
-       linkend="SQL-CREATETABLEAS"><command>CREATE TABLE AS</command></link>
+       linkend="sql-createtableas"><command>CREATE TABLE AS</command></link>
        (Neil)
       </para>
 
@@ -5705,7 +5705,7 @@
      <listitem>
       <para>
        Add <literal>ON COMMIT</literal> clause to <link
-       linkend="SQL-CREATETABLEAS"><command>CREATE TABLE AS</command></link>
+       linkend="sql-createtableas"><command>CREATE TABLE AS</command></link>
        (Neil)
       </para>
 
@@ -5719,7 +5719,7 @@
      <listitem>
       <para>
        Add <literal>INCLUDING CONSTRAINTS</literal> to <link
-       linkend="SQL-CREATETABLE"><command>CREATE TABLE LIKE</command></link>
+       linkend="sql-createtable"><command>CREATE TABLE LIKE</command></link>
        (Greg Stark)
       </para>
 
@@ -5732,7 +5732,7 @@
      <listitem>
       <para>
        Allow the creation of placeholder (shell) <link
-       linkend="SQL-CREATETYPE">types</link> (Martijn van Oosterhout)
+       linkend="sql-createtype">types</link> (Martijn van Oosterhout)
       </para>
 
       <para>
@@ -5747,7 +5747,7 @@
 
      <listitem>
       <para>
-       <link linkend="SQL-CREATEAGGREGATE">Aggregate functions</link>
+       <link linkend="sql-createaggregate">Aggregate functions</link>
        now support multiple input parameters (Sergey Koposov, Tom)
       </para>
      </listitem>
@@ -5755,7 +5755,7 @@
      <listitem>
       <para>
        Add new aggregate creation <link
-       linkend="SQL-CREATEAGGREGATE">syntax</link> (Tom)
+       linkend="sql-createaggregate">syntax</link> (Tom)
       </para>
 
       <para>
@@ -5770,7 +5770,7 @@
      <listitem>
       <para>
        Add <link
-       linkend="SQL-ALTERROLE"><command>ALTER ROLE PASSWORD NULL</command></link>
+       linkend="sql-alterrole"><command>ALTER ROLE PASSWORD NULL</command></link>
        to remove a previously set role password (Peter)
       </para>
      </listitem>
@@ -5789,14 +5789,14 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-DROP-OWNED"><literal>DROP OWNED</literal></link>
+       Add <link linkend="sql-drop-owned"><literal>DROP OWNED</literal></link>
        to drop all objects owned by a role (Alvaro)
       </para>
      </listitem>
 
      <listitem>
       <para>
-       Add <link linkend="SQL-REASSIGN-OWNED"><literal>REASSIGN
+       Add <link linkend="sql-reassign-owned"><literal>REASSIGN
        OWNED</literal></link> to reassign ownership of all objects owned
        by a role (Alvaro)
       </para>
@@ -5809,7 +5809,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-GRANT"><command>GRANT ON SEQUENCE</command></link>
+       Add <link linkend="sql-grant"><command>GRANT ON SEQUENCE</command></link>
        syntax (Bruce)
       </para>
 
@@ -5822,7 +5822,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-GRANT"><literal>USAGE</literal></link>
+       Add <link linkend="sql-grant"><literal>USAGE</literal></link>
        permission for sequences that allows only <function>currval()</function>
        and <function>nextval()</function>, not <function>setval()</function>
        (Bruce)
@@ -5839,7 +5839,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-ALTERTABLE"><literal>ALTER TABLE
+       Add <link linkend="sql-altertable"><literal>ALTER TABLE
        [ NO ] INHERIT</literal></link> (Greg Stark)
       </para>
 
@@ -5852,7 +5852,7 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-COMMENT">comments</link> on global
+       Allow <link linkend="sql-comment">comments</link> on global
        objects to be stored globally (Kris Jurka)
       </para>
 
@@ -5881,7 +5881,7 @@
       </para>
 
       <para>
-       The new syntax is <link linkend="SQL-CREATEINDEX"><command>CREATE
+       The new syntax is <link linkend="sql-createindex"><command>CREATE
        INDEX CONCURRENTLY</command></link>.  The default behavior is
        still to block table modification while an index is being
        created.
@@ -5902,7 +5902,7 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-COPY"><command>COPY</command></link> to
+       Allow <link linkend="sql-copy"><command>COPY</command></link> to
        dump a <command>SELECT</command> query (Zoltan Boszormenyi, Karel
        Zak)
       </para>
@@ -5915,7 +5915,7 @@
 
      <listitem>
       <para>
-       Make the <link linkend="SQL-COPY"><command>COPY</command></link>
+       Make the <link linkend="sql-copy"><command>COPY</command></link>
        command return a command tag that includes the number of
        rows copied (Volkan YAZICI)
       </para>
@@ -5923,7 +5923,7 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-VACUUM"><command>VACUUM</command></link>
+       Allow <link linkend="sql-vacuum"><command>VACUUM</command></link>
        to expire rows without being affected by other concurrent
        <command>VACUUM</command> operations (Hannu Krossing, Alvaro, Tom)
       </para>
@@ -5931,7 +5931,7 @@
 
      <listitem>
       <para>
-       Make <link linkend="APP-INITDB"><application>initdb</application></link>
+       Make <link linkend="app-initdb"><application>initdb</application></link>
        detect the operating system locale and set the default
        <varname>DateStyle</varname> accordingly (Peter)
       </para>
@@ -6154,7 +6154,7 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-CREATEDOMAIN">domains</link> to be
+       Allow <link linkend="sql-createdomain">domains</link> to be
        based on other domains (Tom)
       </para>
      </listitem>
@@ -6185,7 +6185,7 @@
        The fix is to dump a <type>SERIAL</type> column by explicitly
        specifying its <literal>DEFAULT</literal> and sequence elements,
        and reconstructing the <type>SERIAL</type> column on reload
-       using a new <link linkend="SQL-ALTERSEQUENCE"><command>ALTER
+       using a new <link linkend="sql-altersequence"><command>ALTER
        SEQUENCE OWNED BY</command></link> command.  This also allows
        dropping a <type>SERIAL</type> column specification.
       </para>
@@ -6353,7 +6353,7 @@
    </sect3>
 
    <sect3>
-    <title><link linkend="APP-PSQL"><application>psql</application></link> Changes</title>
+    <title><link linkend="app-psql"><application>psql</application></link> Changes</title>
     <itemizedlist>
 
      <listitem>
@@ -6461,7 +6461,7 @@
    </sect3>
 
    <sect3>
-    <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link> Changes</title>
+    <title><link linkend="app-pgdump"><application>pg_dump</application></link> Changes</title>
     <itemizedlist>
 
      <listitem>
@@ -6484,7 +6484,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="APP-PGRESTORE"><application>pg_restore</application></link>
+       Add <link linkend="app-pgrestore"><application>pg_restore</application></link>
        <literal>--no-data-for-failed-tables</literal> option to suppress
        loading data if table creation failed (i.e., the table already
        exists) (Martin Pitt)
@@ -6493,7 +6493,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="APP-PGRESTORE"><application>pg_restore</application></link>
+       Add <link linkend="app-pgrestore"><application>pg_restore</application></link>
        option to run the entire session in a single transaction
        (Simon)
       </para>
@@ -6520,7 +6520,7 @@
 
       <para>
        This allows passwords to be sent pre-encrypted for commands
-       like <link linkend="SQL-ALTERROLE"><command>ALTER ROLE ...
+       like <link linkend="sql-alterrole"><command>ALTER ROLE ...
        PASSWORD</command></link>.
       </para>
      </listitem>
@@ -6582,14 +6582,14 @@
 
      <listitem>
       <para>
-       Allow <link linkend="SQL-SHOW"><command>SHOW</command></link> to
+       Allow <link linkend="sql-show"><command>SHOW</command></link> to
        put its result into a variable (Joachim Wieland)
       </para>
      </listitem>
 
      <listitem>
       <para>
-       Add <link linkend="SQL-COPY"><command>COPY TO STDOUT</command></link>
+       Add <link linkend="sql-copy"><command>COPY TO STDOUT</command></link>
        (Joachim Wieland)
       </para>
      </listitem>
@@ -6624,7 +6624,7 @@
      <listitem>
       <para>
        Add <acronym>MSVC</acronym> support for utility commands and <link
-       linkend="APP-PGDUMP"><application>pg_dump</application></link> (Hiroshi
+       linkend="app-pgdump"><application>pg_dump</application></link> (Hiroshi
        Saito)
       </para>
      </listitem>
@@ -6670,7 +6670,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="GIN"><acronym>GIN</acronym></link> (Generalized
+       Add <link linkend="gin"><acronym>GIN</acronym></link> (Generalized
        Inverted iNdex) index access method (Teodor, Oleg)
       </para>
      </listitem>
@@ -6682,7 +6682,7 @@
 
       <para>
        Rtree has been re-implemented using <link
-       linkend="GiST"><acronym>GiST</acronym></link>. Among other
+       linkend="gist"><acronym>GiST</acronym></link>. Among other
        differences, this means that rtree indexes now have support
        for crash recovery via write-ahead logging (WAL).
       </para>
diff --git a/doc/src/sgml/release-8.3.sgml b/doc/src/sgml/release-8.3.sgml
index 45ecf9c054a..844f7961794 100644
--- a/doc/src/sgml/release-8.3.sgml
+++ b/doc/src/sgml/release-8.3.sgml
@@ -7867,7 +7867,7 @@ current_date &lt; 2017-11-17
    </sect3>
 
    <sect3>
-    <title><link linkend="APP-PSQL"><application>psql</application></link></title>
+    <title><link linkend="app-psql"><application>psql</application></link></title>
     <itemizedlist>
 
      <listitem>
@@ -7956,7 +7956,7 @@ current_date &lt; 2017-11-17
    </sect3>
 
    <sect3>
-    <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link></title>
+    <title><link linkend="app-pgdump"><application>pg_dump</application></link></title>
     <itemizedlist>
 
      <listitem>
diff --git a/doc/src/sgml/release-9.0.sgml b/doc/src/sgml/release-9.0.sgml
index e09f38e1808..7a8db62b8d8 100644
--- a/doc/src/sgml/release-9.0.sgml
+++ b/doc/src/sgml/release-9.0.sgml
@@ -7742,9 +7742,9 @@
     <listitem>
      <para>
       Easier database object permissions management. <link
-      linkend="SQL-GRANT"><command>GRANT</command>/<command>REVOKE IN
+      linkend="sql-grant"><command>GRANT</command>/<command>REVOKE IN
       SCHEMA</command></link> supports mass permissions changes on existing objects,
-      while <link linkend="SQL-ALTERDEFAULTPRIVILEGES"><command>ALTER DEFAULT
+      while <link linkend="sql-alterdefaultprivileges"><command>ALTER DEFAULT
       PRIVILEGES</command></link> allows control of privileges for objects created in
       the future.  Large objects (BLOBs) now support permissions management as
       well.
@@ -7754,7 +7754,7 @@
     <listitem>
      <para>
       Broadly enhanced stored procedure support.
-      The <link linkend="SQL-DO"><command>DO</command></link> statement supports
+      The <link linkend="sql-do"><command>DO</command></link> statement supports
       ad-hoc or <quote>anonymous</quote> code blocks.
       Functions can now be called using named parameters.
       <link linkend="plpgsql">PL/pgSQL</link> is now installed by default, and
@@ -7783,14 +7783,14 @@
      <para>
       New trigger features, including
       SQL-standard-compliant <link
-      linkend="SQL-CREATETRIGGER">per-column triggers</link> and
+      linkend="sql-createtrigger">per-column triggers</link> and
       conditional trigger execution.
      </para>
     </listitem>
 
     <listitem>
      <para>
-      <link linkend="SQL-CREATETABLE-compatibility">Deferrable
+      <link linkend="sql-createtable-compatibility">Deferrable
       unique constraints</link>. Mass updates to unique keys are now possible
       without trickery.
      </para>
@@ -7816,8 +7816,8 @@
     <listitem>
      <para>
       New high-performance implementation of the
-      <link linkend="SQL-LISTEN"><command>LISTEN</command></link>/<link
-      linkend="SQL-NOTIFY"><command>NOTIFY</command></link> feature.
+      <link linkend="sql-listen"><command>LISTEN</command></link>/<link
+      linkend="sql-notify"><command>NOTIFY</command></link> feature.
       Pending events are now stored in a memory-based queue rather than
       a table.  Also, a <quote>payload</quote> string can be sent with each
       event, rather than transmitting just an event name as before.
@@ -7827,7 +7827,7 @@
     <listitem>
      <para>
       New implementation of
-      <link linkend="SQL-VACUUM"><command>VACUUM FULL</command></link>.
+      <link linkend="sql-vacuum"><command>VACUUM FULL</command></link>.
       This command now rewrites the entire table and indexes, rather than
       moving individual rows to compact space.  It is substantially faster
       in most cases, and no longer results in index bloat.
@@ -8287,7 +8287,7 @@
       <para>
        Allow per-tablespace values to be set for sequential and random page
        cost estimates (<varname>seq_page_cost</varname>/<varname>random_page_cost</varname>)
-       via <link linkend="SQL-ALTERTABLESPACE"><command>ALTER TABLESPACE
+       via <link linkend="sql-altertablespace"><command>ALTER TABLESPACE
        ... SET/RESET</command></link> (Robert Haas)
       </para>
      </listitem>
@@ -8308,7 +8308,7 @@
      <listitem>
       <para>
        Improve performance of <link
-       linkend="SQL-TRUNCATE"><command>TRUNCATE</command></link> when
+       linkend="sql-truncate"><command>TRUNCATE</command></link> when
        the table was created or truncated earlier in the same transaction
        (Tom Lane)
       </para>
@@ -8414,7 +8414,7 @@
 
      <listitem>
       <para>
-       Improve <link linkend="SQL-ANALYZE"><command>ANALYZE</command></link>
+       Improve <link linkend="sql-analyze"><command>ANALYZE</command></link>
        to support inheritance-tree statistics (Tom Lane)
       </para>
 
@@ -8451,7 +8451,7 @@
      <listitem>
       <para>
        Allow setting of number-of-distinct-values statistics using <link
-       linkend="SQL-ALTERTABLE"><command>ALTER TABLE</command></link>
+       linkend="sql-altertable"><command>ALTER TABLE</command></link>
        (Robert Haas)
       </para>
 
@@ -8707,7 +8707,7 @@
 
     <listitem>
      <para>
-      Perform <link linkend="SQL-FOR-UPDATE-SHARE"><command>SELECT
+      Perform <link linkend="sql-for-update-share"><command>SELECT
       FOR UPDATE</command>/<literal>SHARE</literal></link> processing after
       applying <literal>LIMIT</literal>, so the number of rows returned
       is always predictable (Tom Lane)
@@ -8725,7 +8725,7 @@
     <listitem>
      <para>
       Allow mixing of traditional and SQL-standard <link
-      linkend="SQL-LIMIT"><literal>LIMIT</literal>/<literal>OFFSET</literal></link>
+      linkend="sql-limit"><literal>LIMIT</literal>/<literal>OFFSET</literal></link>
       syntax (Tom Lane)
      </para>
     </listitem>
@@ -8733,7 +8733,7 @@
     <listitem>
      <para>
       Extend the supported frame options in <link
-      linkend="SQL-WINDOW">window functions</link> (Hitoshi
+      linkend="sql-window">window functions</link> (Hitoshi
       Harada)
      </para>
 
@@ -8795,7 +8795,7 @@
 
     <listitem>
      <para>
-      Speed up <link linkend="SQL-CREATEDATABASE"><command>CREATE
+      Speed up <link linkend="sql-createdatabase"><command>CREATE
       DATABASE</command></link> by deferring flushes to disk (Andres
       Freund, Greg Stark)
      </para>
@@ -8803,7 +8803,7 @@
 
     <listitem>
      <para>
-      Allow <link linkend="SQL-COMMENT">comments</link> on
+      Allow <link linkend="sql-comment">comments</link> on
       columns of tables, views, and composite types only, not other
       relation types such as indexes and <acronym>TOAST</acronym> tables (Tom Lane)
      </para>
@@ -8812,7 +8812,7 @@
     <listitem>
      <para>
       Allow the creation of <link
-      linkend="SQL-CREATETYPE-enum">enumerated types</link> containing
+      linkend="sql-createtype-enum">enumerated types</link> containing
       no values (Bruce Momjian)
      </para>
     </listitem>
@@ -8870,7 +8870,7 @@
    </sect4>
 
    <sect4>
-    <title><link linkend="SQL-CREATETABLE"><command>CREATE TABLE</command></link></title>
+    <title><link linkend="sql-createtable"><command>CREATE TABLE</command></link></title>
 
     <itemizedlist>
 
@@ -8914,7 +8914,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-CREATETABLE-compatibility">deferrable
+       Add <link linkend="sql-createtable-compatibility">deferrable
        unique constraints</link> (Dean Rasheed)
       </para>
 
@@ -8941,7 +8941,7 @@
       <para>
        Exclusion constraints generalize uniqueness constraints by allowing
        arbitrary comparison operators, not just equality.  They are created
-       with the <link linkend="SQL-CREATETABLE-EXCLUDE"><command>CREATE
+       with the <link linkend="sql-createtable-exclude"><command>CREATE
        TABLE CONSTRAINT ... EXCLUDE</command></link> clause.
        The most common use of exclusion constraints is to specify that column
        entries must not overlap, rather than simply not be equal.  This is
@@ -8976,7 +8976,7 @@
       <para>
        Add the ability to make mass permission changes across a whole
        schema using the new <link
-       linkend="SQL-GRANT"><command>GRANT</command>/<command>REVOKE
+       linkend="sql-grant"><command>GRANT</command>/<command>REVOKE
        IN SCHEMA</command></link> clause (Petr Jelinek)
       </para>
 
@@ -8989,7 +8989,7 @@
 
      <listitem>
       <para>
-       Add <link linkend="SQL-ALTERDEFAULTPRIVILEGES"><command>ALTER
+       Add <link linkend="sql-alterdefaultprivileges"><command>ALTER
        DEFAULT PRIVILEGES</command></link> command to control privileges
        of objects created later (Petr Jelinek)
       </para>
@@ -9028,8 +9028,8 @@
 
     <listitem>
      <para>
-      Make <link linkend="SQL-LISTEN"><command>LISTEN</command></link>/<link
-      linkend="SQL-NOTIFY"><command>NOTIFY</command></link> store pending events
+      Make <link linkend="sql-listen"><command>LISTEN</command></link>/<link
+      linkend="sql-notify"><command>NOTIFY</command></link> store pending events
       in a memory queue, rather than in a system table (Joachim
       Wieland)
      </para>
@@ -9042,7 +9042,7 @@
 
     <listitem>
      <para>
-      Allow <link linkend="SQL-NOTIFY"><command>NOTIFY</command></link>
+      Allow <link linkend="sql-notify"><command>NOTIFY</command></link>
       to pass an optional <quote>payload</quote> string to listeners
       (Joachim Wieland)
      </para>
@@ -9056,7 +9056,7 @@
 
     <listitem>
      <para>
-      Allow <link linkend="SQL-CLUSTER"><command>CLUSTER</command></link>
+      Allow <link linkend="sql-cluster"><command>CLUSTER</command></link>
       on all per-database system catalogs (Tom Lane)
      </para>
 
@@ -9068,7 +9068,7 @@
    </itemizedlist>
 
    <sect4>
-    <title><link linkend="SQL-COPY"><command>COPY</command></link></title>
+    <title><link linkend="sql-copy"><command>COPY</command></link></title>
 
     <itemizedlist>
 
@@ -9101,7 +9101,7 @@
    </sect4>
 
    <sect4>
-    <title><link linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link></title>
+    <title><link linkend="sql-explain"><command>EXPLAIN</command></link></title>
 
     <itemizedlist>
 
@@ -9156,7 +9156,7 @@
    </sect4>
 
    <sect4>
-    <title><link linkend="SQL-VACUUM"><command>VACUUM</command></link></title>
+    <title><link linkend="sql-vacuum"><command>VACUUM</command></link></title>
 
     <itemizedlist>
 
@@ -9200,7 +9200,7 @@
      <listitem>
       <para>
        Allow an index to be named automatically by omitting the index name in
-       <link linkend="SQL-CREATEINDEX"><command>CREATE INDEX</command></link>
+       <link linkend="sql-createindex"><command>CREATE INDEX</command></link>
        (Tom Lane)
       </para>
      </listitem>
@@ -9581,7 +9581,7 @@
      <listitem>
       <para>
        Support execution of anonymous code blocks using the <link
-       linkend="SQL-DO"><command>DO</command></link> statement
+       linkend="sql-do"><command>DO</command></link> statement
        (Petr Jelinek, Joshua Tolley, Hannu Valtonen)
       </para>
 
@@ -9595,7 +9595,7 @@
      <listitem>
       <para>
        Implement SQL-standard-compliant <link
-       linkend="SQL-CREATETRIGGER">per-column triggers</link>
+       linkend="sql-createtrigger">per-column triggers</link>
        (Itagaki Takahiro)
       </para>
 
@@ -9609,7 +9609,7 @@
      <listitem>
       <para>
        Add the <literal>WHEN</literal> clause to <link
-       linkend="SQL-CREATETRIGGER"><command>CREATE TRIGGER</command></link>
+       linkend="sql-createtrigger"><command>CREATE TRIGGER</command></link>
        to allow control over whether a trigger is fired (Itagaki
        Takahiro)
       </para>
@@ -9635,7 +9635,7 @@
     <listitem>
      <para>
       Add the <literal>OR REPLACE</literal> clause to <link
-      linkend="SQL-CREATELANGUAGE"><command>CREATE LANGUAGE</command></link>
+      linkend="sql-createlanguage"><command>CREATE LANGUAGE</command></link>
       (Tom Lane)
      </para>
 
@@ -9937,7 +9937,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
     <listitem>
     <para>
      Add an <option>--analyze-only</option> option to <link
-     linkend="APP-VACUUMDB"><command>vacuumdb</command></link>, to analyze without
+     linkend="app-vacuumdb"><command>vacuumdb</command></link>, to analyze without
      vacuuming (Bruce Momjian)
      </para>
     </listitem>
@@ -9945,14 +9945,14 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
    </itemizedlist>
 
    <sect4>
-    <title><link linkend="APP-PSQL"><application>psql</application></link></title>
+    <title><link linkend="app-psql"><application>psql</application></link></title>
 
     <itemizedlist>
 
      <listitem>
       <para>
        Add support for quoting/escaping the values of <application>psql</application>
-       <link linkend="APP-PSQL-variables">variables</link> as SQL strings or
+       <link linkend="app-psql-variables">variables</link> as SQL strings or
        identifiers (Pavel Stehule, Robert Haas)
       </para>
 
@@ -9980,7 +9980,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
      <listitem>
       <para>
        Fix <command>psql --file -</command> to properly honor <link
-       linkend="R1-APP-PSQL-3"><option>--single-transaction</option></link>
+       linkend="r1-app-psql-3"><option>--single-transaction</option></link>
        (Bruce Momjian)
       </para>
      </listitem>
@@ -10039,7 +10039,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
 
     <sect5>
      <title><application>psql</application> <link
-     linkend="APP-PSQL-meta-commands"><command>\d</command></link>
+     linkend="app-psql-meta-commands"><command>\d</command></link>
      Commands</title>
 
      <itemizedlist>
@@ -10084,7 +10084,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
    </sect4>
 
    <sect4>
-    <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link></title>
+    <title><link linkend="app-pgdump"><application>pg_dump</application></link></title>
 
     <itemizedlist>
 
@@ -10990,7 +10990,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
     <listitem>
      <para>
       Add <link
-      linkend="CONTRIB-DBLINK-GET-NOTIFY"><function>dblink_get_notify()</function></link>
+      linkend="contrib-dblink-get-notify"><function>dblink_get_notify()</function></link>
       to <filename>contrib/dblink</filename> (Marcus Kempe)
      </para>
 
@@ -11007,7 +11007,7 @@ if TG_OP = 'INSERT' and NEW.col1 = ... then
 
      <para>
       This affects <link
-      linkend="CONTRIB-DBLINK-BUILD-SQL-INSERT"><function>dblink_build_sql_insert()</function></link>
+      linkend="contrib-dblink-build-sql-insert"><function>dblink_build_sql_insert()</function></link>
       and related functions.  These functions now number columns according
       to logical not physical column numbers.
      </para>
diff --git a/doc/src/sgml/release-9.1.sgml b/doc/src/sgml/release-9.1.sgml
index 29396316098..92948a4ad02 100644
--- a/doc/src/sgml/release-9.1.sgml
+++ b/doc/src/sgml/release-9.1.sgml
@@ -8816,7 +8816,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
     <listitem>
      <para>
-      Add support for <link linkend="SQL-CREATEFOREIGNTABLE">foreign
+      Add support for <link linkend="sql-createforeigntable">foreign
       tables</link>
      </para>
     </listitem>
@@ -8845,7 +8845,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     <listitem>
      <para>
       Support unlogged tables using the <literal>UNLOGGED</literal>
-      option in <link linkend="SQL-CREATETABLE"><command>CREATE
+      option in <link linkend="sql-createtable"><command>CREATE
       TABLE</command></link>
      </para>
     </listitem>
@@ -8861,13 +8861,13 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     <listitem>
      <para>
       Add nearest-neighbor (order-by-operator) searching to <link
-      linkend="GiST"><acronym>GiST</acronym> indexes</link>
+      linkend="gist"><acronym>GiST</acronym> indexes</link>
      </para>
     </listitem>
 
     <listitem>
      <para>
-      Add a <link linkend="SQL-SECURITY-LABEL"><command>SECURITY
+      Add a <link linkend="sql-security-label"><command>SECURITY
       LABEL</command></link> command and support for
       <link linkend="sepgsql"><acronym>SELinux</acronym> permissions control</link>
      </para>
@@ -9154,7 +9154,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
      <listitem>
       <para>
        All contrib modules are now installed with <link
-       linkend="SQL-CREATEEXTENSION"><command>CREATE EXTENSION</command></link>
+       linkend="sql-createextension"><command>CREATE EXTENSION</command></link>
        rather than by manually invoking their SQL scripts
        (Dimitri Fontaine, Tom Lane)
       </para>
@@ -9229,7 +9229,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
       <listitem>
        <para>
         Support unlogged tables using the <literal>UNLOGGED</literal>
-        option in <link linkend="SQL-CREATETABLE"><command>CREATE
+        option in <link linkend="sql-createtable"><command>CREATE
         TABLE</command></link> (Robert Haas)
        </para>
 
@@ -9643,7 +9643,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
      <listitem>
       <para>
-       Add a <link linkend="SQL-CREATEROLE">replication permission</link>
+       Add a <link linkend="sql-createrole">replication permission</link>
        for roles (Magnus Hagander)
       </para>
 
@@ -9986,9 +9986,9 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
        <para>
         Extensions are controlled by the new <link
-        linkend="SQL-CREATEEXTENSION"><command>CREATE</command></link>/<link
-        linkend="SQL-ALTEREXTENSION"><command>ALTER</command></link>/<link
-        linkend="SQL-DROPEXTENSION"><command>DROP EXTENSION</command></link>
+        linkend="sql-createextension"><command>CREATE</command></link>/<link
+        linkend="sql-alterextension"><command>ALTER</command></link>/<link
+        linkend="sql-dropextension"><command>DROP EXTENSION</command></link>
         commands.  This replaces ad-hoc methods of grouping objects that
         are added to a <productname>PostgreSQL</productname> installation.
        </para>
@@ -9996,7 +9996,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
       <listitem>
        <para>
-        Add support for <link linkend="SQL-CREATEFOREIGNTABLE">foreign
+        Add support for <link linkend="sql-createforeigntable">foreign
         tables</link> (Shigeru Hanada, Robert Haas, Jan Urbanski,
         Heikki Linnakangas)
        </para>
@@ -10011,14 +10011,14 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
      <listitem>
       <para>
          Allow new values to be added to an existing enum type via
-         <link linkend="SQL-ALTERTYPE"><command>ALTER TYPE</command></link> (Andrew
+         <link linkend="sql-altertype"><command>ALTER TYPE</command></link> (Andrew
          Dunstan)
       </para>
      </listitem>
 
       <listitem>
        <para>
-        Add <link linkend="SQL-ALTERTYPE"><command>ALTER TYPE ...
+        Add <link linkend="sql-altertype"><command>ALTER TYPE ...
         ADD/DROP/ALTER/RENAME ATTRIBUTE</command></link> (Peter Eisentraut)
        </para>
 
@@ -10037,7 +10037,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
       <listitem>
        <para>
         Add <literal>RESTRICT</literal>/<literal>CASCADE</literal> to <link
-        linkend="SQL-ALTERTYPE"><command>ALTER TYPE</command></link> operations
+        linkend="sql-altertype"><command>ALTER TYPE</command></link> operations
         on typed tables (Peter Eisentraut)
        </para>
 
@@ -10079,7 +10079,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     </sect4>
 
     <sect4>
-     <title><link linkend="SQL-CREATETABLE"><command>CREATE/ALTER TABLE</command></link></title>
+     <title><link linkend="sql-createtable"><command>CREATE/ALTER TABLE</command></link></title>
 
      <itemizedlist>
 
@@ -10112,7 +10112,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
       <listitem>
        <para>
-        Allow <link linkend="SQL-ALTERTABLE"><command>ALTER TABLE
+        Allow <link linkend="sql-altertable"><command>ALTER TABLE
         ... SET DATA TYPE</command></link> to avoid table rewrites in
         appropriate cases (Noah Misch, Robert Haas)
        </para>
@@ -10127,7 +10127,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
       <listitem>
        <para>
-        Add <link linkend="SQL-CREATETABLE"><command>CREATE TABLE IF
+        Add <link linkend="sql-createtable"><command>CREATE TABLE IF
         NOT EXISTS</command></link> syntax (Robert Haas)
        </para>
 
@@ -10162,7 +10162,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
       <listitem>
        <para>
-        Add a <link linkend="SQL-SECURITY-LABEL"><command>SECURITY
+        Add a <link linkend="sql-security-label"><command>SECURITY
         LABEL</command></link> command (KaiGai Kohei)
        </para>
 
@@ -10196,7 +10196,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
      <listitem>
       <para>
-       Make <link linkend="SQL-TRUNCATE"><command>TRUNCATE ... RESTART
+       Make <link linkend="sql-truncate"><command>TRUNCATE ... RESTART
        IDENTITY</command></link> restart sequences transactionally (Steve
        Singer)
       </para>
@@ -10211,14 +10211,14 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     </itemizedlist>
 
     <sect4>
-     <title><link linkend="SQL-COPY"><command>COPY</command></link></title>
+     <title><link linkend="sql-copy"><command>COPY</command></link></title>
 
      <itemizedlist>
 
       <listitem>
        <para>
         Add <literal>ENCODING</literal> option to <link
-        linkend="SQL-COPY"><command>COPY TO/FROM</command></link> (Hitoshi
+        linkend="sql-copy"><command>COPY TO/FROM</command></link> (Hitoshi
         Harada, Itagaki Takahiro)
        </para>
 
@@ -10230,7 +10230,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
 
       <listitem>
        <para>
-        Add bidirectional <link linkend="SQL-COPY"><command>COPY</command></link>
+        Add bidirectional <link linkend="sql-copy"><command>COPY</command></link>
         protocol support (Fujii Masao)
        </para>
 
@@ -10244,7 +10244,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     </sect4>
 
     <sect4>
-     <title><link linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link></title>
+     <title><link linkend="sql-explain"><command>EXPLAIN</command></link></title>
 
       <itemizedlist>
 
@@ -10260,15 +10260,15 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     </sect4>
 
     <sect4>
-     <title><link linkend="SQL-VACUUM"><command>VACUUM</command></link></title>
+     <title><link linkend="sql-vacuum"><command>VACUUM</command></link></title>
 
      <itemizedlist>
 
       <listitem>
        <para>
         Add additional details to the output of <link
-        linkend="SQL-VACUUM"><command>VACUUM FULL VERBOSE</command></link>
-        and <link linkend="SQL-CLUSTER"><command>CLUSTER VERBOSE</command></link>
+        linkend="sql-vacuum"><command>VACUUM FULL VERBOSE</command></link>
+        and <link linkend="sql-cluster"><command>CLUSTER VERBOSE</command></link>
         (Itagaki Takahiro)
        </para>
 
@@ -10294,7 +10294,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
     </sect4>
 
     <sect4>
-     <title><link linkend="SQL-CLUSTER"><command>CLUSTER</command></link></title>
+     <title><link linkend="sql-cluster"><command>CLUSTER</command></link></title>
 
      <itemizedlist>
 
@@ -10317,7 +10317,7 @@ Branch: REL9_0_STABLE [9d6af7367] 2015-08-15 11:02:34 -0400
       <listitem>
        <para>
         Add nearest-neighbor (order-by-operator) searching to <link
-        linkend="GiST"><acronym>GiST</acronym> indexes</link> (Teodor Sigaev, Tom Lane)
+        linkend="gist"><acronym>GiST</acronym> indexes</link> (Teodor Sigaev, Tom Lane)
        </para>
 
        <para>
@@ -10334,7 +10334,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
       <listitem>
        <para>
-        Allow <link linkend="GIN"><acronym>GIN</acronym> indexes</link> to index null
+        Allow <link linkend="gin"><acronym>GIN</acronym> indexes</link> to index null
         and empty values (Tom Lane)
        </para>
 
@@ -10346,7 +10346,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
       <listitem>
        <para>
-        Allow <link linkend="GIN"><acronym>GIN</acronym> indexes</link> to
+        Allow <link linkend="gin"><acronym>GIN</acronym> indexes</link> to
         better recognize duplicate search entries (Tom Lane)
        </para>
 
@@ -10358,7 +10358,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
       <listitem>
        <para>
-        Fix <link linkend="GiST"><acronym>GiST</acronym> indexes</link> to be fully
+        Fix <link linkend="gist"><acronym>GiST</acronym> indexes</link> to be fully
         crash-safe (Heikki Linnakangas)
        </para>
 
@@ -10668,7 +10668,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
       <listitem>
        <para>
-        Support <link linkend="SQL-CREATETRIGGER"><literal>INSTEAD
+        Support <link linkend="sql-createtrigger"><literal>INSTEAD
         OF</literal></link> triggers on views (Dean Rasheed)
        </para>
 
@@ -10869,7 +10869,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
     </itemizedlist>
 
     <sect4>
-     <title><link linkend="APP-PSQL"><application>psql</application></link></title>
+     <title><link linkend="app-psql"><application>psql</application></link></title>
 
      <itemizedlist>
 
@@ -10963,15 +10963,15 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
     </sect4>
 
     <sect4>
-     <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link></title>
+     <title><link linkend="app-pgdump"><application>pg_dump</application></link></title>
 
      <itemizedlist>
 
       <listitem>
        <para>
-         Add <link linkend="APP-PGDUMP"><application>pg_dump</application></link>
+         Add <link linkend="app-pgdump"><application>pg_dump</application></link>
          and <link
-         linkend="APP-PG-DUMPALL"><application>pg_dumpall</application></link>
+         linkend="app-pg-dumpall"><application>pg_dumpall</application></link>
          option <option>--quote-all-identifiers</option> to force quoting
          of all identifiers (Robert Haas)
        </para>
@@ -10994,7 +10994,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
     </sect4>
 
     <sect4>
-     <title><link linkend="APP-PG-CTL"><application>pg_ctl</application></link></title>
+     <title><link linkend="app-pg-ctl"><application>pg_ctl</application></link></title>
 
      <itemizedlist>
 
@@ -11528,7 +11528,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
 
        <para>
         This uses the new <link
-        linkend="SQL-SECURITY-LABEL"><command>SECURITY LABEL</command></link>
+        linkend="sql-security-label"><command>SECURITY LABEL</command></link>
         facility.
        </para>
       </listitem>
@@ -11716,7 +11716,7 @@ SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10;
      <listitem>
       <para>
        Merge documentation for <command>CREATE CONSTRAINT TRIGGER</command> and <link
-       linkend="SQL-CREATETRIGGER"><command>CREATE TRIGGER</command></link>
+       linkend="sql-createtrigger"><command>CREATE TRIGGER</command></link>
        (Alvaro Herrera)
       </para>
      </listitem>
diff --git a/doc/src/sgml/release-9.2.sgml b/doc/src/sgml/release-9.2.sgml
index ca8c87a4aba..edc97fb8e78 100644
--- a/doc/src/sgml/release-9.2.sgml
+++ b/doc/src/sgml/release-9.2.sgml
@@ -9091,7 +9091,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Add the <link linkend="SPGiST">SP-GiST</link> (Space-Partitioned
+        Add the <link linkend="spgist">SP-GiST</link> (Space-Partitioned
         GiST) index access method
        </para>
       </listitem>
@@ -9112,7 +9112,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add a <link
-        linkend="SQL-CREATEVIEW"><literal>security_barrier</literal></link>
+        linkend="sql-createview"><literal>security_barrier</literal></link>
         option for views
        </para>
       </listitem>
@@ -9300,7 +9300,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Prevent  <link linkend="SQL-ALTERDOMAIN"><command>ALTER
+        Prevent  <link linkend="sql-alterdomain"><command>ALTER
         DOMAIN</command></link> from working on non-domain types (Peter
         Eisentraut)
        </para>
@@ -9314,7 +9314,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         No longer forcibly lowercase procedural language names in <link
-        linkend="SQL-CREATEFUNCTION"><command>CREATE FUNCTION</command></link>
+        linkend="sql-createfunction"><command>CREATE FUNCTION</command></link>
         (Robert Haas)
        </para>
 
@@ -9352,7 +9352,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
        <para>
         Provide consistent backquote, variable
         expansion, and quoted substring behavior in <link
-        linkend="APP-PSQL"><application>psql</application></link> meta-command
+        linkend="app-psql"><application>psql</application></link> meta-command
         arguments (Tom Lane)
        </para>
 
@@ -9368,9 +9368,9 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         No longer treat <link
-        linkend="APP-CLUSTERDB"><application>clusterdb</application></link>
+        linkend="app-clusterdb"><application>clusterdb</application></link>
         table names as double-quoted; no longer treat <link
-        linkend="APP-REINDEXDB"><application>reindexdb</application></link> table
+        linkend="app-reindexdb"><application>reindexdb</application></link> table
         and index names as double-quoted (Bruce Momjian)
        </para>
 
@@ -9382,7 +9382,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        <link linkend="APP-CREATEUSER"><application>createuser</application></link>
+        <link linkend="app-createuser"><application>createuser</application></link>
         no longer prompts for option settings by default (Peter Eisentraut)
        </para>
 
@@ -9394,7 +9394,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Disable prompting for the user name in <link
-        linkend="APP-DROPUSER"><application>dropuser</application></link> unless
+        linkend="app-dropuser"><application>dropuser</application></link> unless
         <option>--interactive</option> is specified (Peter Eisentraut)
        </para>
       </listitem>
@@ -9556,7 +9556,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Add the <link linkend="SPGiST">SP-GiST</link> (Space-Partitioned
+        Add the <link linkend="spgist">SP-GiST</link> (Space-Partitioned
         GiST) index access method (Teodor Sigaev, Oleg Bartunov, Tom
         Lane)
        </para>
@@ -10385,7 +10385,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add <literal>CONCURRENTLY</literal> option to <link
-        linkend="SQL-DROPINDEX"><command>DROP INDEX</command></link>
+        linkend="sql-dropindex"><command>DROP INDEX</command></link>
         (Simon Riggs)
        </para>
 
@@ -10450,7 +10450,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Add the ability to <link linkend="SQL-ALTERTABLE">rename</link>
+        Add the ability to <link linkend="sql-altertable">rename</link>
         constraints (Peter Eisentraut)
        </para>
       </listitem>
@@ -10466,7 +10466,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Reduce need to rebuild tables and indexes for certain <link
-        linkend="SQL-ALTERTABLE"><command>ALTER TABLE</command></link>
+        linkend="sql-altertable"><command>ALTER TABLE</command></link>
         ... <literal>ALTER COLUMN TYPE</literal> operations (Noah Misch)
        </para>
 
@@ -10484,7 +10484,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Avoid having <link linkend="SQL-ALTERTABLE"><command>ALTER
+        Avoid having <link linkend="sql-altertable"><command>ALTER
         TABLE</command></link> revalidate foreign key constraints in some
         cases where it is not necessary (Noah Misch)
        </para>
@@ -10504,16 +10504,16 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Add <link linkend="SQL-ALTERFOREIGNDATAWRAPPER"><command>ALTER
+        Add <link linkend="sql-alterforeigndatawrapper"><command>ALTER
         FOREIGN DATA WRAPPER</command></link> ... <literal>RENAME</literal>
-        and <link linkend="SQL-ALTERSERVER"><command>ALTER
+        and <link linkend="sql-alterserver"><command>ALTER
         SERVER</command></link> ... <literal>RENAME</literal> (Peter Eisentraut)
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Add <link linkend="SQL-ALTERDOMAIN"><command>ALTER
+        Add <link linkend="sql-alterdomain"><command>ALTER
         DOMAIN</command></link> ... <literal>RENAME</literal> (Peter Eisentraut)
        </para>
 
@@ -10540,7 +10540,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
     </sect4>
 
     <sect4>
-     <title><link linkend="SQL-CREATETABLE"><command>CREATE TABLE</command></link></title>
+     <title><link linkend="sql-createtable"><command>CREATE TABLE</command></link></title>
 
      <itemizedlist>
 
@@ -10583,7 +10583,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add a <link
-        linkend="SQL-CREATEVIEW"><literal>security_barrier</literal></link>
+        linkend="sql-createview"><literal>security_barrier</literal></link>
         option for views (KaiGai Kohei, Robert Haas)
        </para>
 
@@ -10599,7 +10599,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add a new <link
-        linkend="SQL-CREATEFUNCTION"><literal>LEAKPROOF</literal></link> function
+        linkend="sql-createfunction"><literal>LEAKPROOF</literal></link> function
         attribute to mark functions that can safely be pushed down
         into <literal>security_barrier</literal> views (KaiGai Kohei)
        </para>
@@ -10646,7 +10646,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Allow <link linkend="SQL-VACUUM"><command>VACUUM</command></link> to more
+        Allow <link linkend="sql-vacuum"><command>VACUUM</command></link> to more
         easily skip pages that cannot be locked (Simon Riggs, Robert Haas)
        </para>
 
@@ -10658,7 +10658,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Make <link linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link>
+        Make <link linkend="sql-explain"><command>EXPLAIN</command></link>
         <literal>(BUFFERS)</literal> count blocks dirtied and written (Robert Haas)
        </para>
       </listitem>
@@ -10738,7 +10738,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Allow <link linkend="SQL-CREATEDOMAIN">domains</link> to be
+        Allow <link linkend="sql-createdomain">domains</link> to be
         declared <literal>NOT VALID</literal> (&Aacute;lvaro Herrera)
        </para>
 
@@ -10828,7 +10828,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
         database state.
         Snapshots are exported via <link
         linkend="functions-snapshot-synchronization"><function>pg_export_snapshot()</function></link>
-        and imported via <link linkend="SQL-SET-TRANSACTION"><command>SET
+        and imported via <link linkend="sql-set-transaction"><command>SET
         TRANSACTION SNAPSHOT</command></link>.  Only snapshots from
         currently-running transactions can be imported.
        </para>
@@ -11083,7 +11083,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
 
       <listitem>
        <para>
-        Add <link linkend="APP-INITDB"><application>initdb</application></link>
+        Add <link linkend="app-initdb"><application>initdb</application></link>
         options <option>--auth-local</option> and <option>--auth-host</option>
         (Peter Eisentraut)
        </para>
@@ -11098,7 +11098,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add <option>--replication</option>/<option>--no-replication</option> flags to
-        <link linkend="APP-CREATEUSER"><application>createuser</application></link>
+        <link linkend="app-createuser"><application>createuser</application></link>
         to control replication permission (Fujii Masao)
        </para>
       </listitem>
@@ -11106,8 +11106,8 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Add the <option>--if-exists</option> option to <link
-        linkend="APP-DROPDB"><application>dropdb</application></link> and <link
-        linkend="APP-DROPUSER"><application>dropuser</application></link> (Josh
+        linkend="app-dropdb"><application>dropdb</application></link> and <link
+        linkend="app-dropuser"><application>dropuser</application></link> (Josh
         Kupershmidt)
        </para>
       </listitem>
@@ -11123,7 +11123,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
     </itemizedlist>
 
     <sect4>
-     <title><link linkend="APP-PSQL"><application>psql</application></link></title>
+     <title><link linkend="app-psql"><application>psql</application></link></title>
 
      <itemizedlist>
 
@@ -11309,7 +11309,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
        <para>
         In <application>psql</application> tab completion, complete <acronym>SQL</acronym>
         keywords in either upper or lower case according to the new <link
-        linkend="APP-PSQL-variables"><literal>COMP_KEYWORD_CASE</literal></link>
+        linkend="app-psql-variables"><literal>COMP_KEYWORD_CASE</literal></link>
         setting (Peter Eisentraut)
        </para>
       </listitem>
@@ -11348,7 +11348,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
     </sect4>
 
     <sect4>
-     <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link></title>
+     <title><link linkend="app-pgdump"><application>pg_dump</application></link></title>
 
      <itemizedlist>
 
@@ -11380,7 +11380,7 @@ Branch: REL9_2_STABLE [6b700301c] 2015-02-17 16:03:00 +0100
       <listitem>
        <para>
         Make <link
-        linkend="APP-PG-DUMPALL"><application>pg_dumpall</application></link> dump all
+        linkend="app-pg-dumpall"><application>pg_dumpall</application></link> dump all
         roles first, then all configuration settings on roles (Phil Sorber)
        </para>
 
diff --git a/doc/src/sgml/release-9.3.sgml b/doc/src/sgml/release-9.3.sgml
index dada2550575..84523d36b74 100644
--- a/doc/src/sgml/release-9.3.sgml
+++ b/doc/src/sgml/release-9.3.sgml
@@ -10497,7 +10497,7 @@ ALTER EXTENSION hstore UPDATE;
 
     <listitem>
      <para>
-      Add <link linkend="SQL-CREATEMATERIALIZEDVIEW">materialized
+      Add <link linkend="sql-creatematerializedview">materialized
       views</link>
      </para>
     </listitem>
@@ -10505,7 +10505,7 @@ ALTER EXTENSION hstore UPDATE;
     <listitem>
      <para>
       Make simple views <link
-      linkend="SQL-CREATEVIEW-updatable-views">auto-updatable</link>
+      linkend="sql-createview-updatable-views">auto-updatable</link>
      </para>
     </listitem>
 
@@ -10527,7 +10527,7 @@ ALTER EXTENSION hstore UPDATE;
 
     <listitem>
      <para>
-      Allow <link linkend="SQL-CREATEFOREIGNDATAWRAPPER">foreign data
+      Allow <link linkend="sql-createforeigndatawrapper">foreign data
       wrappers</link> to support writes (inserts/updates/deletes) on foreign
       tables
      </para>
@@ -10582,7 +10582,7 @@ ALTER EXTENSION hstore UPDATE;
 
    <para>
     A dump/restore using <link
-    linkend="APP-PG-DUMPALL"><application>pg_dumpall</application></link>, or use
+    linkend="app-pg-dumpall"><application>pg_dumpall</application></link>, or use
     of <link linkend="pgupgrade"><application>pg_upgrade</application></link>, is
     required for those wishing to migrate data from any previous release.
    </para>
@@ -10664,7 +10664,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Change multicolumn <link linkend="SQL-CREATETABLE"><literal>ON UPDATE
+        Change multicolumn <link linkend="sql-createtable"><literal>ON UPDATE
         SET NULL/SET DEFAULT</literal></link> foreign key actions to affect
         all columns of the constraint, not just those changed in the
         <command>UPDATE</command> (Tom Lane)
@@ -10818,7 +10818,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Allow <link linkend="GiST"><acronym>GiST</acronym></link> indexes to be
+        Allow <link linkend="gist"><acronym>GiST</acronym></link> indexes to be
         unlogged (Jeevan Chalke)
        </para>
       </listitem>
@@ -10893,7 +10893,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Add <link linkend="SQL-COPY"><command>COPY FREEZE</command></link>
+        Add <link linkend="sql-copy"><command>COPY FREEZE</command></link>
         option to avoid the overhead of marking tuples as frozen later
         (Simon Riggs, Jeff Davis)
        </para>
@@ -10922,7 +10922,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Improve performance of the <link
-        linkend="SQL-CREATETABLE"><command>CREATE TEMPORARY TABLE ... ON
+        linkend="sql-createtable"><command>CREATE TEMPORARY TABLE ... ON
         COMMIT DELETE ROWS</command></link> option by not truncating such temporary
         tables in transactions that haven't touched any temporary tables
         (Heikki Linnakangas)
@@ -10989,7 +10989,7 @@ ALTER EXTENSION hstore UPDATE;
 
        <para>
         The checksum option can be set during <link
-        linkend="APP-INITDB">initdb</link>.
+        linkend="app-initdb">initdb</link>.
        </para>
       </listitem>
 
@@ -11139,7 +11139,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Increase the maximum <link
-        linkend="APP-INITDB">initdb</link>-configured value for <link
+        linkend="app-initdb">initdb</link>-configured value for <link
         linkend="guc-shared-buffers"><varname>shared_buffers</varname></link>
         to 128MB (Robert Haas)
        </para>
@@ -11216,7 +11216,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Add the last checkpoint's redo location to <link
-        linkend="APP-PGCONTROLDATA"><application>pg_controldata</application></link>'s
+        linkend="app-pgcontroldata"><application>pg_controldata</application></link>'s
         output (Fujii Masao)
        </para>
 
@@ -11318,8 +11318,8 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Add support for piping <link
-        linkend="SQL-COPY"><command>COPY</command></link> and <link
-        linkend="APP-PSQL"><application>psql</application></link> <command>\copy</command>
+        linkend="sql-copy"><command>COPY</command></link> and <link
+        linkend="app-psql"><application>psql</application></link> <command>\copy</command>
         data to/from an external program (Etsuro Fujita)
        </para>
       </listitem>
@@ -11327,7 +11327,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Allow a multirow <link
-        linkend="SQL-VALUES"><literal>VALUES</literal></link> clause in a rule
+        linkend="sql-values"><literal>VALUES</literal></link> clause in a rule
         to reference <literal>OLD</literal>/<literal>NEW</literal> (Tom Lane)
        </para>
       </listitem>
@@ -11355,7 +11355,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Allow <link linkend="SQL-CREATEFOREIGNDATAWRAPPER">foreign data
+        Allow <link linkend="sql-createforeigndatawrapper">foreign data
         wrappers</link> to support writes (inserts/updates/deletes) on foreign
         tables (KaiGai Kohei)
        </para>
@@ -11363,14 +11363,14 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Add <link linkend="SQL-CREATESCHEMA"><command>CREATE SCHEMA ... IF
+        Add <link linkend="sql-createschema"><command>CREATE SCHEMA ... IF
         NOT EXISTS</command></link> clause (Fabr&iacute;zio de Royes Mello)
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Make <link linkend="SQL-REASSIGN-OWNED"><command>REASSIGN
+        Make <link linkend="sql-reassign-owned"><command>REASSIGN
         OWNED</command></link> also change ownership of shared objects
         (&Aacute;lvaro Herrera)
        </para>
@@ -11386,7 +11386,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Suppress <link linkend="SQL-CREATETABLE"><command>CREATE
+        Suppress <link linkend="sql-createtable"><command>CREATE
         TABLE</command></link>'s messages about implicit index and sequence creation
         (Robert Haas)
        </para>
@@ -11399,7 +11399,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Allow <link linkend="SQL-DROPTABLE"><command>DROP TABLE IF
+        Allow <link linkend="sql-droptable"><command>DROP TABLE IF
         EXISTS</command></link> to succeed when a non-existent schema is specified
         in the table name (Bruce Momjian)
        </para>
@@ -11434,7 +11434,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Support <literal>IF NOT EXISTS</literal> option in <link
-        linkend="SQL-ALTERTYPE"><command>ALTER TYPE ... ADD VALUE</command></link>
+        linkend="sql-altertype"><command>ALTER TYPE ... ADD VALUE</command></link>
         (Andrew Dunstan)
        </para>
 
@@ -11445,13 +11445,13 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Add <link linkend="SQL-ALTERROLE"><command>ALTER ROLE ALL
+        Add <link linkend="sql-alterrole"><command>ALTER ROLE ALL
         SET</command></link> to establish settings for all users (Peter Eisentraut)
        </para>
 
        <para>
         This allows settings to apply to all users in all databases. <link
-        linkend="SQL-ALTERDATABASE"><command>ALTER DATABASE SET</command></link>
+        linkend="sql-alterdatabase"><command>ALTER DATABASE SET</command></link>
         already allowed addition of settings for all users in a single
         database.  <filename>postgresql.conf</filename> has a similar effect.
        </para>
@@ -11459,7 +11459,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Add support for <link linkend="SQL-ALTERRULE"><command>ALTER RULE
+        Add support for <link linkend="sql-alterrule"><command>ALTER RULE
         ... RENAME</command></link> (Ali Dar)
        </para>
       </listitem>
@@ -11475,7 +11475,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Add <link linkend="SQL-CREATEMATERIALIZEDVIEW">materialized
+        Add <link linkend="sql-creatematerializedview">materialized
         views</link> (Kevin Grittner)
        </para>
 
@@ -11491,7 +11491,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Make simple views <link
-        linkend="SQL-CREATEVIEW-updatable-views">auto-updatable</link>
+        linkend="sql-createview-updatable-views">auto-updatable</link>
         (Dean Rasheed)
        </para>
 
@@ -11499,14 +11499,14 @@ ALTER EXTENSION hstore UPDATE;
         Simple views that reference some or all columns from a
         single base table are now updatable by default. More
         complex views can be made updatable using <link
-        linkend="SQL-CREATETRIGGER"><literal>INSTEAD OF</literal></link> triggers
-        or <link linkend="SQL-CREATERULE"><literal>INSTEAD</literal></link> rules.
+        linkend="sql-createtrigger"><literal>INSTEAD OF</literal></link> triggers
+        or <link linkend="sql-createrule"><literal>INSTEAD</literal></link> rules.
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Add <link linkend="SQL-CREATEVIEW"><command>CREATE RECURSIVE
+        Add <link linkend="sql-createview"><command>CREATE RECURSIVE
         VIEW</command></link> syntax (Peter Eisentraut)
        </para>
 
@@ -11545,7 +11545,7 @@ ALTER EXTENSION hstore UPDATE;
 
       <listitem>
        <para>
-        Increase the maximum size of <link linkend="largeObjects">large
+        Increase the maximum size of <link linkend="largeobjects">large
         objects</link> from 2GB to 4TB (Nozomi Anzai, Yugo Nagata)
        </para>
 
@@ -11675,7 +11675,7 @@ ALTER EXTENSION hstore UPDATE;
 
        <para>
         This reduces line length in view printing, for instance in <link
-        linkend="APP-PGDUMP"><application>pg_dump</application></link> output.
+        linkend="app-pgdump"><application>pg_dump</application></link> output.
        </para>
       </listitem>
 
@@ -11728,7 +11728,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Allow PL/pgSQL to access the number of rows processed by
-        <link linkend="SQL-COPY"><command>COPY</command></link> (Pavel Stehule)
+        <link linkend="sql-copy"><command>COPY</command></link> (Pavel Stehule)
        </para>
 
        <para>
@@ -11818,7 +11818,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Allow <acronym>SPI</acronym> functions to access the number of rows processed
-        by <link linkend="SQL-COPY"><command>COPY</command></link> (Pavel Stehule)
+        by <link linkend="sql-copy"><command>COPY</command></link> (Pavel Stehule)
        </para>
       </listitem>
 
@@ -11842,16 +11842,16 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Support multiple <option>--table</option> arguments for <link
-        linkend="APP-PGRESTORE"><application>pg_restore</application></link>,
-        <link linkend="APP-CLUSTERDB"><application>clusterdb</application></link>,
-        <link linkend="APP-REINDEXDB"><application>reindexdb</application></link>,
-        and <link linkend="APP-VACUUMDB"><application>vacuumdb</application></link>
+        linkend="app-pgrestore"><application>pg_restore</application></link>,
+        <link linkend="app-clusterdb"><application>clusterdb</application></link>,
+        <link linkend="app-reindexdb"><application>reindexdb</application></link>,
+        and <link linkend="app-vacuumdb"><application>vacuumdb</application></link>
         (Josh Kupershmidt)
        </para>
 
        <para>
         This is similar to the way <link
-        linkend="APP-PGDUMP"><application>pg_dump</application></link>'s
+        linkend="app-pgdump"><application>pg_dump</application></link>'s
         <option>--table</option> option works.
        </para>
       </listitem>
@@ -11859,7 +11859,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Add <option>--dbname</option> option to <link
-        linkend="APP-PG-DUMPALL"><application>pg_dumpall</application></link>, <link
+        linkend="app-pg-dumpall"><application>pg_dumpall</application></link>, <link
         linkend="app-pgbasebackup"><application>pg_basebackup</application></link>, and
         <link
         linkend="app-pgreceivewal"><application>pg_receivexlog</application></link>
@@ -11879,7 +11879,7 @@ ALTER EXTENSION hstore UPDATE;
     </itemizedlist>
 
     <sect4>
-     <title><link linkend="APP-PSQL"><application>psql</application></link></title>
+     <title><link linkend="app-psql"><application>psql</application></link></title>
 
      <itemizedlist>
 
@@ -11924,7 +11924,7 @@ ALTER EXTENSION hstore UPDATE;
      </itemizedlist>
 
     <sect5>
-     <title><link linkend="APP-PSQL-meta-commands">Backslash Commands</link></title>
+     <title><link linkend="app-psql-meta-commands">Backslash Commands</link></title>
 
      <itemizedlist>
 
@@ -12035,7 +12035,7 @@ ALTER EXTENSION hstore UPDATE;
     </sect4>
 
     <sect4>
-     <title><link linkend="APP-PGDUMP"><application>pg_dump</application></link></title>
+     <title><link linkend="app-pgdump"><application>pg_dump</application></link></title>
 
      <itemizedlist>
 
@@ -12076,7 +12076,7 @@ ALTER EXTENSION hstore UPDATE;
     </sect4>
 
     <sect4>
-     <title><link linkend="APP-INITDB"><application>initdb</application></link></title>
+     <title><link linkend="app-initdb"><application>initdb</application></link></title>
 
      <itemizedlist>
 
@@ -12208,7 +12208,7 @@ ALTER EXTENSION hstore UPDATE;
       <listitem>
        <para>
         Add isolation tests for <link
-        linkend="SQL-CREATEINDEX"><command>CREATE INDEX
+        linkend="sql-createindex"><command>CREATE INDEX
         CONCURRENTLY</command></link> (Abhijit Menon-Sen)
        </para>
       </listitem>
diff --git a/doc/src/sgml/release-9.4.sgml b/doc/src/sgml/release-9.4.sgml
index deb74b4e1c2..f6c38bd9128 100644
--- a/doc/src/sgml/release-9.4.sgml
+++ b/doc/src/sgml/release-9.4.sgml
@@ -8490,14 +8490,14 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
      <listitem>
       <para>
-       Add new <acronym>SQL</acronym> command <xref linkend="SQL-ALTERSYSTEM">
+       Add new <acronym>SQL</acronym> command <xref linkend="sql-altersystem">
        for changing <filename>postgresql.conf</filename> configuration file entries
       </para>
      </listitem>
 
      <listitem>
       <para>
-       Reduce lock strength for some <xref linkend="SQL-ALTERTABLE">
+       Reduce lock strength for some <xref linkend="sql-altertable">
        commands
       </para>
      </listitem>
@@ -8686,7 +8686,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
     <listitem>
      <para>
-      Rename <link linkend="SQL-EXPLAIN"><command>EXPLAIN
+      Rename <link linkend="sql-explain"><command>EXPLAIN
       ANALYZE</command></link>'s <quote>total runtime</quote> output
       to <quote>execution time</quote> (Tom Lane)
      </para>
@@ -8699,7 +8699,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
     <listitem>
      <para>
-      <link linkend="SQL-SHOW"><command>SHOW TIME ZONE</command></link> now
+      <link linkend="sql-show"><command>SHOW TIME ZONE</command></link> now
       outputs simple numeric UTC offsets in <acronym>POSIX</acronym> timezone
       format (Tom Lane)
      </para>
@@ -8924,7 +8924,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Make <xref linkend="SQL-VACUUM"> properly report dead but
+        Make <xref linkend="sql-vacuum"> properly report dead but
         not-yet-removable rows to the statistics collector (Hari Babu)
        </para>
 
@@ -8942,14 +8942,14 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Reduce <link linkend="GIN"><acronym>GIN</acronym></link> index size
+        Reduce <link linkend="gin"><acronym>GIN</acronym></link> index size
         (Alexander Korotkov, Heikki Linnakangas)
        </para>
 
        <para>
         Indexes upgraded via <xref linkend="pgupgrade"> will work fine
         but will still be in the old, larger <acronym>GIN</acronym> format.
-        Use <xref linkend="SQL-REINDEX"> to recreate old GIN indexes in the
+        Use <xref linkend="sql-reindex"> to recreate old GIN indexes in the
         new format.
        </para>
       </listitem>
@@ -8957,14 +8957,14 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
       <listitem>
        <para>
         Improve speed of multi-key <link
-        linkend="GIN"><acronym>GIN</acronym></link> lookups (Alexander Korotkov,
+        linkend="gin"><acronym>GIN</acronym></link> lookups (Alexander Korotkov,
         Heikki Linnakangas)
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Add <link linkend="GiST"><acronym>GiST</acronym></link> index support
+        Add <link linkend="gist"><acronym>GiST</acronym></link> index support
         for <link linkend="datatype-inet"><type>inet</type></link> and
         <link linkend="datatype-cidr"><type>cidr</type></link> data types
         (Emre Hasegeli)
@@ -9038,8 +9038,8 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        <para>
         Attempt to <link linkend="vacuum-for-wraparound">freeze</link>
         tuples when tables are rewritten with <xref
-        linkend="SQL-CLUSTER"> or <link
-        linkend="SQL-VACUUM"><command>VACUUM FULL</command></link> (Robert Haas,
+        linkend="sql-cluster"> or <link
+        linkend="sql-vacuum"><command>VACUUM FULL</command></link> (Robert Haas,
         Andres Freund)
        </para>
 
@@ -9050,7 +9050,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Improve speed of <xref linkend="SQL-COPY"> with default <link
+        Improve speed of <xref linkend="sql-copy"> with default <link
         linkend="functions-sequence-table"><function>nextval()</function></link>
         columns (Simon Riggs)
        </para>
@@ -9059,7 +9059,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
       <listitem>
        <para>
         Improve speed of accessing many different <link
-        linkend="SQL-CREATESEQUENCE">sequences</link> in the same session
+        linkend="sql-createsequence">sequences</link> in the same session
         (David Rowley)
        </para>
       </listitem>
@@ -9074,7 +9074,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
       <listitem>
        <para>
         Reduce memory allocated by <application>PL/pgSQL</application>
-        <xref linkend="SQL-DO"> blocks (Tom Lane)
+        <xref linkend="sql-do"> blocks (Tom Lane)
        </para>
       </listitem>
 
@@ -9222,7 +9222,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Add new <acronym>SQL</acronym> command <xref linkend="SQL-ALTERSYSTEM">
+        Add new <acronym>SQL</acronym> command <xref linkend="sql-altersystem">
         for changing <filename>postgresql.conf</filename> configuration file entries
         (Amit Kapila)
        </para>
@@ -9503,7 +9503,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        <listitem>
         <para>
          Add relation option <link
-         linkend="SQL-CREATETABLE-storage-parameters"><option>user_catalog_table</option></link>
+         linkend="sql-createtable-storage-parameters"><option>user_catalog_table</option></link>
          to identify user-created tables involved in logical change-set
          encoding (Andres Freund)
         </para>
@@ -9558,7 +9558,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Allow <xref linkend="SQL-SELECT"> to have
+        Allow <xref linkend="sql-select"> to have
         an empty target list (Tom Lane)
        </para>
 
@@ -9570,7 +9570,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Ensure that <link linkend="SQL-SELECT"><literal>SELECT ... FOR UPDATE
+        Ensure that <link linkend="sql-select"><literal>SELECT ... FOR UPDATE
         NOWAIT</literal></link> does not wait in corner cases involving
         already-concurrently-updated tuples (Craig Ringer and Thomas Munro)
        </para>
@@ -9587,7 +9587,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Add <link linkend="SQL-DISCARD"><command>DISCARD
+        Add <link linkend="sql-discard"><command>DISCARD
         SEQUENCES</command></link> command to discard cached sequence-related state
         (Fabr&iacute;zio de Royes Mello, Robert Haas)
        </para>
@@ -9600,7 +9600,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        <listitem>
         <para>
          Add <literal>FORCE NULL</literal> option
-         to <link linkend="SQL-COPY"><command>COPY FROM</command></link>, which
+         to <link linkend="sql-copy"><command>COPY FROM</command></link>, which
          causes quoted strings matching the specified null string to be
          converted to NULLs in <literal>CSV</literal> mode (Ian Barwick, Michael
          Paquier)
@@ -9628,7 +9628,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
      </itemizedlist>
 
      <sect4>
-      <title><xref linkend="SQL-EXPLAIN"></title>
+      <title><xref linkend="sql-explain"></title>
 
       <itemizedlist>
 
@@ -9671,7 +9671,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
        <para>
         This is done with <link
-        linkend="SQL-REFRESHMATERIALIZEDVIEW"><command>REFRESH MATERIALIZED
+        linkend="sql-refreshmaterializedview"><command>REFRESH MATERIALIZED
         VIEW CONCURRENTLY</command></link>.
        </para>
       </listitem>
@@ -9679,7 +9679,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
       <listitem>
        <para>
         Allow views to be <link
-        linkend="SQL-CREATEVIEW-updatable-views">automatically
+        linkend="sql-createview-updatable-views">automatically
         updated</link> even if they contain some non-updatable columns
         (Dean Rasheed)
        </para>
@@ -9701,7 +9701,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        </para>
 
        <para>
-        This is controlled with the new <xref linkend="SQL-CREATEVIEW">
+        This is controlled with the new <xref linkend="sql-createview">
         clause <literal>WITH CHECK OPTION</literal>.
        </para>
       </listitem>
@@ -9726,7 +9726,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Support triggers on <link linkend="SQL-CREATEFOREIGNTABLE">foreign
+        Support triggers on <link linkend="sql-createforeigntable">foreign
         tables</link> (Ronan Dunklau)
        </para>
       </listitem>
@@ -9735,22 +9735,22 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        <para>
         Allow moving groups of objects from one tablespace to another
         using the <literal>ALL IN TABLESPACE ... SET TABLESPACE</literal> form of
-        <xref linkend="SQL-ALTERTABLE">, <xref linkend="SQL-ALTERINDEX">, or
-        <xref linkend="SQL-ALTERMATERIALIZEDVIEW"> (Stephen Frost)
+        <xref linkend="sql-altertable">, <xref linkend="sql-alterindex">, or
+        <xref linkend="sql-altermaterializedview"> (Stephen Frost)
        </para>
       </listitem>
 
       <listitem>
        <para>
         Allow changing foreign key constraint deferrability
-        via <xref linkend="SQL-ALTERTABLE"> ... <literal>ALTER
+        via <xref linkend="sql-altertable"> ... <literal>ALTER
         CONSTRAINT</literal> (Simon Riggs)
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Reduce lock strength for some <xref linkend="SQL-ALTERTABLE">
+        Reduce lock strength for some <xref linkend="sql-altertable">
         commands
         (Simon Riggs, Noah Misch, Robert Haas)
        </para>
@@ -9768,18 +9768,18 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
       <listitem>
        <para>
         Allow tablespace options to be set
-        in <xref linkend="SQL-CREATETABLESPACE"> (Vik Fearing)
+        in <xref linkend="sql-createtablespace"> (Vik Fearing)
        </para>
 
        <para>
         Formerly these options could only be set
-        via <xref linkend="SQL-ALTERTABLESPACE">.
+        via <xref linkend="sql-altertablespace">.
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Allow <xref linkend="SQL-CREATEAGGREGATE"> to define the estimated
+        Allow <xref linkend="sql-createaggregate"> to define the estimated
         size of the aggregate's transition state data (Hadi Moshayedi)
        </para>
 
@@ -10266,14 +10266,14 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
 
       <listitem>
        <para>
-        Add <xref linkend="APP-CREATEUSER"> option <option>-g</option>
+        Add <xref linkend="app-createuser"> option <option>-g</option>
         to specify role membership (Christopher Browne)
        </para>
       </listitem>
 
       <listitem>
        <para>
-        Add <xref linkend="APP-VACUUMDB">
+        Add <xref linkend="app-vacuumdb">
         option <option>--analyze-in-stages</option> to analyze in stages of
         increasing granularity (Peter Eisentraut)
        </para>
@@ -10343,14 +10343,14 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
     </itemizedlist>
 
     <sect4>
-     <title><xref linkend="APP-PSQL"></title>
+     <title><xref linkend="app-psql"></title>
 
      <itemizedlist>
 
       <listitem>
        <para>
         Suppress <quote>No rows</quote> output in <application>psql</application> <link
-        linkend="APP-PSQL-meta-commands"><option>expanded</option></link>
+        linkend="app-psql-meta-commands"><option>expanded</option></link>
         mode when the footer is disabled (Bruce Momjian)
        </para>
       </listitem>
@@ -10365,7 +10365,7 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
      </itemizedlist>
 
      <sect5>
-      <title><link linkend="APP-PSQL-meta-commands">Backslash Commands</link></title>
+      <title><link linkend="app-psql-meta-commands">Backslash Commands</link></title>
 
       <itemizedlist>
 
@@ -10475,13 +10475,13 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
     </sect4>
 
     <sect4>
-     <title><xref linkend="APP-PGDUMP"></title>
+     <title><xref linkend="app-pgdump"></title>
 
      <itemizedlist>
 
       <listitem>
        <para>
-        Allow <xref linkend="APP-PGRESTORE"> options
+        Allow <xref linkend="app-pgrestore"> options
         <option>-I</option>, <option>-P</option>, <option>-T</option> and <option>-n</option>
         to be specified multiple times (Heikki Linnakangas)
        </para>
@@ -10501,8 +10501,8 @@ Branch: REL9_4_STABLE [c2b06ab17] 2015-01-30 22:45:58 -0500
        <para>
         This change prevents unnecessary errors when removing old objects.
         The new <option>--if-exists</option> option
-        for <xref linkend="APP-PGDUMP">, <xref linkend="APP-PG-DUMPALL">,
-        and <xref linkend="APP-PGRESTORE"> is only available
+        for <xref linkend="app-pgdump">, <xref linkend="app-pg-dumpall">,
+        and <xref linkend="app-pgrestore"> is only available
         when <option>--clean</option> is also specified.
        </para>
       </listitem>
diff --git a/doc/src/sgml/release-9.5.sgml b/doc/src/sgml/release-9.5.sgml
index 2f23abe3295..11740a41089 100644
--- a/doc/src/sgml/release-9.5.sgml
+++ b/doc/src/sgml/release-9.5.sgml
@@ -5726,7 +5726,7 @@ Branch: REL9_1_STABLE [6887d72d0] 2016-02-05 10:59:39 -0500
 
     <listitem>
      <para>
-      Add <link linkend="BRIN">Block Range Indexes</link> (<acronym>BRIN</acronym>)
+      Add <link linkend="brin">Block Range Indexes</link> (<acronym>BRIN</acronym>)
      </para>
     </listitem>
 
@@ -5999,7 +5999,7 @@ max_wal_size = (3 * checkpoint_segments) * 16MB
 2015-05-15 [b0b7be6] Alvaro..: Add BRIN infrastructure for "inclusion" opclasses
 -->
        <para>
-        Add <link linkend="BRIN">Block Range Indexes</link> (<acronym>BRIN</acronym>)
+        Add <link linkend="brin">Block Range Indexes</link> (<acronym>BRIN</acronym>)
         (&Aacute;lvaro Herrera)
        </para>
 
@@ -6018,7 +6018,7 @@ max_wal_size = (3 * checkpoint_segments) * 16MB
        <para>
         Allow queries to perform accurate distance filtering of
         bounding-box-indexed objects (polygons, circles) using <link
-        linkend="GiST">GiST</link> indexes (Alexander Korotkov, Heikki
+        linkend="gist">GiST</link> indexes (Alexander Korotkov, Heikki
         Linnakangas)
        </para>
 
@@ -6038,7 +6038,7 @@ max_wal_size = (3 * checkpoint_segments) * 16MB
 2015-03-30 [0633a60] Heikki..: Add index-only scan support to range type GiST ..
 -->
        <para>
-        Allow <link linkend="GiST">GiST</link> indexes to perform index-only
+        Allow <link linkend="gist">GiST</link> indexes to perform index-only
         scans (Anastasia Lubennikova, Heikki Linnakangas, Andreas Karlsson)
        </para>
       </listitem>
@@ -6540,7 +6540,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-09-02 [bd3b7a9] Fujii ..: Support ALTER SYSTEM RESET command.
 -->
        <para>
-        Allow <link linkend="SQL-ALTERSYSTEM"><command>ALTER SYSTEM</command></link>
+        Allow <link linkend="sql-altersystem"><command>ALTER SYSTEM</command></link>
         values to be reset with <command>ALTER SYSTEM RESET</command> (Vik
         Fearing)
        </para>
@@ -6757,7 +6757,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
        <para>
         Allow setting multiple target columns in
-        an <link linkend="SQL-UPDATE"><command>UPDATE</command></link> from the result of
+        an <link linkend="sql-update"><command>UPDATE</command></link> from the result of
         a single sub-SELECT (Tom Lane)
        </para>
 
@@ -6772,7 +6772,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-10-07 [df630b0] Alvaro..: Implement SKIP LOCKED for row-level locks
 -->
        <para>
-        Add <link linkend="SQL-SELECT"><command>SELECT</command></link> option
+        Add <link linkend="sql-select"><command>SELECT</command></link> option
         <literal>SKIP LOCKED</literal> to skip locked rows (Thomas Munro)
        </para>
 
@@ -6787,7 +6787,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2015-05-15 [f6d208d] Simon ..: TABLESAMPLE, SQL Standard and extensible
 -->
        <para>
-        Add <link linkend="SQL-SELECT"><command>SELECT</command></link> option
+        Add <link linkend="sql-select"><command>SELECT</command></link> option
         <literal>TABLESAMPLE</literal> to return a subset of a table (Petr
         Jel&iacute;nek)
        </para>
@@ -6825,7 +6825,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
        <para>
         Add more details about sort ordering in <link
-        linkend="SQL-EXPLAIN"><command>EXPLAIN</command></link> output (Marius Timmer,
+        linkend="sql-explain"><command>EXPLAIN</command></link> output (Marius Timmer,
         Lukas Kreft, Arne Scheffer)
        </para>
 
@@ -6840,7 +6840,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-12-18 [35192f0] Alvaro..: Have VACUUM log number of skipped pages due to ..
 -->
        <para>
-        Make <link linkend="SQL-VACUUM"><command>VACUUM</command></link> log the
+        Make <link linkend="sql-vacuum"><command>VACUUM</command></link> log the
         number of pages skipped due to pins (Jim Nasby)
        </para>
       </listitem>
@@ -6850,7 +6850,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2015-02-20 [d42358e] Alvaro..: Have TRUNCATE update pgstat tuple counters
 -->
        <para>
-        Make <link linkend="SQL-TRUNCATE"><command>TRUNCATE</command></link> properly
+        Make <link linkend="sql-truncate"><command>TRUNCATE</command></link> properly
         update the <literal>pg_stat</literal>* tuple counters (Alexander Shulgin)
        </para>
       </listitem>
@@ -6858,7 +6858,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
        </itemizedlist>
 
        <sect4>
-        <title><xref linkend="SQL-REINDEX"></title>
+        <title><xref linkend="sql-reindex"></title>
 
         <itemizedlist>
 
@@ -6926,10 +6926,10 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
        <para>
         This feature allows row-by-row control over which users can add,
         modify, or even see rows in a table.  This is controlled by new
-        commands <link linkend="SQL-CREATEPOLICY"><command>CREATE</command></link>/<link
-        linkend="SQL-ALTERPOLICY"><command>ALTER</command></link>/<link
-        linkend="SQL-DROPPOLICY"><command>DROP POLICY</command></link> and <link
-        linkend="SQL-ALTERTABLE"><command>ALTER TABLE ... ENABLE/DISABLE
+        commands <link linkend="sql-createpolicy"><command>CREATE</command></link>/<link
+        linkend="sql-alterpolicy"><command>ALTER</command></link>/<link
+        linkend="sql-droppolicy"><command>DROP POLICY</command></link> and <link
+        linkend="sql-altertable"><command>ALTER TABLE ... ENABLE/DISABLE
         ROW SECURITY</command></link>.
        </para>
       </listitem>
@@ -6941,7 +6941,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
        <para>
         Allow changing of the <acronym>WAL</acronym>
         logging status of a table after creation with <link
-        linkend="SQL-ALTERTABLE"><command>ALTER TABLE ... SET LOGGED /
+        linkend="sql-altertable"><command>ALTER TABLE ... SET LOGGED /
         UNLOGGED</command></link> (Fabr&iacute;zio de Royes Mello)
        </para>
       </listitem>
@@ -6954,10 +6954,10 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
        <para>
         Add <literal>IF NOT EXISTS</literal> clause to <link
-        linkend="SQL-CREATETABLEAS"><command>CREATE TABLE AS</command></link>,
-        <link linkend="SQL-CREATEINDEX"><command>CREATE INDEX</command></link>,
-        <link linkend="SQL-CREATESEQUENCE"><command>CREATE SEQUENCE</command></link>,
-        and <link linkend="SQL-CREATEMATERIALIZEDVIEW"><command>CREATE
+        linkend="sql-createtableas"><command>CREATE TABLE AS</command></link>,
+        <link linkend="sql-createindex"><command>CREATE INDEX</command></link>,
+        <link linkend="sql-createsequence"><command>CREATE SEQUENCE</command></link>,
+        and <link linkend="sql-creatematerializedview"><command>CREATE
         MATERIALIZED VIEW</command></link> (Fabr&iacute;zio de Royes Mello)
        </para>
       </listitem>
@@ -6968,7 +6968,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
        <para>
         Add support for <literal>IF EXISTS</literal> to <link
-        linkend="SQL-ALTERTABLE"><command>ALTER TABLE ... RENAME
+        linkend="sql-altertable"><command>ALTER TABLE ... RENAME
         CONSTRAINT</command></link> (Bruce Momjian)
        </para>
       </listitem>
@@ -6986,8 +6986,8 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 
        <para>
         This feature is now supported in
-        <xref linkend="SQL-ALTERUSER">, <xref linkend="SQL-ALTERGROUP">,
-        <xref linkend="SQL-ALTERROLE">, <xref linkend="SQL-GRANT">,
+        <xref linkend="sql-alteruser">, <xref linkend="sql-altergroup">,
+        <xref linkend="sql-alterrole">, <xref linkend="sql-grant">,
         and <command>ALTER <replaceable>object</replaceable> OWNER TO</command> commands.
        </para>
       </listitem>
@@ -6997,7 +6997,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-12-23 [7eca575] Alvaro..: get_object_address: separate domain constraints..
 -->
        <para>
-        Support comments on <link linkend="SQL-CREATEDOMAIN">domain
+        Support comments on <link linkend="sql-createdomain">domain
         constraints</link> (&Aacute;lvaro Herrera)
        </para>
       </listitem>
@@ -7017,7 +7017,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2015-05-11 [fa26424] Stephe..: Allow LOCK TABLE .. ROW EXCLUSIVE MODE with IN..
 -->
        <para>
-        Allow <link linkend="SQL-LOCK"><command>LOCK TABLE ... ROW EXCLUSIVE
+        Allow <link linkend="sql-lock"><command>LOCK TABLE ... ROW EXCLUSIVE
         MODE</command></link> for those with <command>INSERT</command> privileges on the
         target table (Stephen Frost)
        </para>
@@ -7049,8 +7049,8 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
        <para>
         Allow <link
-        linkend="SQL-CREATEDATABASE"><command>CREATE</command></link>/<link
-        linkend="SQL-ALTERDATABASE"><command>ALTER DATABASE</command></link>
+        linkend="sql-createdatabase"><command>CREATE</command></link>/<link
+        linkend="sql-alterdatabase"><command>ALTER DATABASE</command></link>
         to manipulate <structname>datistemplate</structname> and
         <structname>datallowconn</structname> (Vik Fearing)
        </para>
@@ -7075,7 +7075,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-07-10 [59efda3] Tom Lane: Implement IMPORT FOREIGN SCHEMA.
 -->
        <para>
-        Add support for <xref linkend="SQL-IMPORTFOREIGNSCHEMA">
+        Add support for <xref linkend="sql-importforeignschema">
         (Ronan Dunklau, Michael Paquier, Tom Lane)
        </para>
 
@@ -7164,7 +7164,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
         <para>
          Allow event triggers on table rewrites caused by <link
-         linkend="SQL-ALTERTABLE"><command>ALTER TABLE</command></link> (Dimitri
+         linkend="sql-altertable"><command>ALTER TABLE</command></link> (Dimitri
          Fontaine)
         </para>
        </listitem>
@@ -7175,10 +7175,10 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
         <para>
          Add event trigger support for database-level <link
-         linkend="SQL-COMMENT"><command>COMMENT</command></link>, <link
-         linkend="SQL-SECURITY-LABEL"><command>SECURITY LABEL</command></link>,
-         and <link linkend="SQL-GRANT"><command>GRANT</command></link>/<link
-         linkend="SQL-REVOKE"><command>REVOKE</command></link> (&Aacute;lvaro Herrera)
+         linkend="sql-comment"><command>COMMENT</command></link>, <link
+         linkend="sql-security-label"><command>SECURITY LABEL</command></link>,
+         and <link linkend="sql-grant"><command>GRANT</command></link>/<link
+         linkend="sql-revoke"><command>REVOKE</command></link> (&Aacute;lvaro Herrera)
         </para>
        </listitem>
 
@@ -7645,8 +7645,8 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 
       <para>
        This change adds new commands <link
-       linkend="SQL-CREATETRANSFORM"><command>CREATE</command></link>/<link
-       linkend="SQL-DROPTRANSFORM"><command>DROP TRANSFORM</command></link>.
+       linkend="sql-createtransform"><command>CREATE</command></link>/<link
+       linkend="sql-droptransform"><command>DROP TRANSFORM</command></link>.
        This also adds optional transformations between the <link
        linkend="hstore"><application>hstore</application></link> and <link
        linkend="ltree"><application>ltree</application></link> types to/from <link
@@ -7776,7 +7776,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2015-01-23 [a179232] Alvaro..: vacuumdb: enable parallel mode
 -->
       <para>
-       Allow <link linkend="APP-VACUUMDB"><application>vacuumdb</application></link> to
+       Allow <link linkend="app-vacuumdb"><application>vacuumdb</application></link> to
        vacuum in parallel using new <option>--jobs</option> option (Dilip Kumar)
       </para>
      </listitem>
@@ -7786,7 +7786,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2015-11-12 [5094da9] Alvaro..: vacuumdb: don't prompt for passwords over and ..
 -->
       <para>
-       In <link linkend="APP-VACUUMDB"><application>vacuumdb</application></link>, do not
+       In <link linkend="app-vacuumdb"><application>vacuumdb</application></link>, do not
        prompt for the same password repeatedly when multiple connections
        are necessary (Haribabu Kommi, Michael Paquier)
       </para>
@@ -7798,7 +7798,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
       <para>
        Add <option>--verbose</option> option to <link
-       linkend="APP-REINDEXDB"><application>reindexdb</application></link> (Sawada
+       linkend="app-reindexdb"><application>reindexdb</application></link> (Sawada
        Masahiko)
       </para>
      </listitem>
@@ -7829,7 +7829,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
     </itemizedlist>
 
      <sect4>
-      <title><xref linkend="APP-PSQL"></title>
+      <title><xref linkend="app-psql"></title>
 
       <itemizedlist>
 
@@ -7879,7 +7879,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
         <para>
          Add new option <literal>%l</literal> in <application>psql</application>'s <link
-         linkend="APP-PSQL-variables"><envar>PROMPT</envar></link> variables
+         linkend="app-psql-variables"><envar>PROMPT</envar></link> variables
          to display the current multiline statement line number
          (Sawada Masahiko)
         </para>
@@ -7891,7 +7891,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 -->
         <para>
          Add <literal>\pset</literal> option <link
-         linkend="APP-PSQL-meta-commands"><varname>pager_min_lines</varname></link>
+         linkend="app-psql-meta-commands"><varname>pager_min_lines</varname></link>
          to control pager invocation (Andrew Dunstan)
         </para>
        </listitem>
@@ -7949,7 +7949,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
       </itemizedlist>
 
      <sect5>
-      <title><link linkend="APP-PSQL-meta-commands">Backslash Commands</link></title>
+      <title><link linkend="app-psql-meta-commands">Backslash Commands</link></title>
 
       <itemizedlist>
 
@@ -8045,7 +8045,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
     </sect4>
 
     <sect4>
-     <title><xref linkend="APP-PGDUMP"></title>
+     <title><xref linkend="app-pgdump"></title>
 
      <itemizedlist>
 
@@ -8640,7 +8640,7 @@ Add GUC and storage parameter to set the maximum size of GIN pending list.
 2014-11-21 [3a82bc6] Heikki..: Add pageinspect functions for inspecting GIN in..
 -->
       <para>
-       Add <link linkend="GIN"><acronym>GIN</acronym></link>
+       Add <link linkend="gin"><acronym>GIN</acronym></link>
        index inspection functions to <link
        linkend="pageinspect"><application>pageinspect</application></link> (Heikki
        Linnakangas, Peter Geoghegan, Michael Paquier)
diff --git a/doc/src/sgml/release-9.6.sgml b/doc/src/sgml/release-9.6.sgml
index a89b1b58796..90b4ed3585c 100644
--- a/doc/src/sgml/release-9.6.sgml
+++ b/doc/src/sgml/release-9.6.sgml
@@ -5048,7 +5048,7 @@ and many others in the same vein
 2015-09-02 [30bb26b5e] Allow usage of huge maintenance_work_mem for GIN build.
 -->
        <para>
-        Allow <link linkend="GIN"><acronym>GIN</acronym></link> index builds to
+        Allow <link linkend="gin"><acronym>GIN</acronym></link> index builds to
         make effective use of <xref linkend="guc-maintenance-work-mem">
         settings larger than 1 GB (Robert Abraham, Teodor Sigaev)
        </para>
@@ -5094,7 +5094,7 @@ and many others in the same vein
 -->
        <para>
         Improve handling of dead index tuples in <link
-        linkend="GiST">GiST</link> indexes (Anastasia Lubennikova)
+        linkend="gist">GiST</link> indexes (Anastasia Lubennikova)
        </para>
 
        <para>
@@ -5110,7 +5110,7 @@ and many others in the same vein
 2016-03-30 [acdf2a8b3] Introduce SP-GiST operator class over box.
 -->
        <para>
-        Add an <link linkend="SPGiST">SP-GiST</link> operator class for
+        Add an <link linkend="spgist">SP-GiST</link> operator class for
         type <type>box</type> (Alexander Lebedev)
        </para>
       </listitem>
@@ -7228,8 +7228,8 @@ This commit is also listed under psql and PL/pgSQL
 -->
        <para>
         Add a <option>--strict-names</option> option
-        to <link linkend="APP-PGDUMP"><application>pg_dump</application></link>
-        and <link linkend="APP-PGRESTORE"><application>pg_restore</application></link>
+        to <link linkend="app-pgdump"><application>pg_dump</application></link>
+        and <link linkend="app-pgrestore"><application>pg_restore</application></link>
         (Pavel Stehule)
        </para>
 
@@ -7292,7 +7292,7 @@ This commit is also listed under psql and PL/pgSQL
     </itemizedlist>
 
      <sect4>
-      <title><xref linkend="APP-PSQL"></title>
+      <title><xref linkend="app-psql"></title>
 
       <itemizedlist>
 
diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml
index 095bf6459c6..819f2a82946 100644
--- a/doc/src/sgml/rules.sgml
+++ b/doc/src/sgml/rules.sgml
@@ -29,8 +29,8 @@
      execution.  It is very powerful, and can be used for many things
      such as query language procedures, views, and versions.  The
      theoretical foundations and the power of this rule system are
-     also discussed in <xref linkend="STON90b"> and <xref
-     linkend="ONG90">.
+     also discussed in <xref linkend="ston90b"> and <xref
+     linkend="ong90">.
 </para>
 
 <sect1 id="querytree">
diff --git a/doc/src/sgml/spgist.sgml b/doc/src/sgml/spgist.sgml
index 3f2d31b4c09..1b5f654a1b9 100644
--- a/doc/src/sgml/spgist.sgml
+++ b/doc/src/sgml/spgist.sgml
@@ -1,6 +1,6 @@
 <!-- doc/src/sgml/spgist.sgml -->
 
-<chapter id="SPGiST">
+<chapter id="spgist">
 <title>SP-GiST Indexes</title>
 
    <indexterm>
diff --git a/doc/src/sgml/start.sgml b/doc/src/sgml/start.sgml
index 7a61b50579e..4a6f746d206 100644
--- a/doc/src/sgml/start.sgml
+++ b/doc/src/sgml/start.sgml
@@ -268,7 +268,7 @@ createdb: database creation failed: ERROR:  permission denied to create database
 
    <para>
     More about <command>createdb</command> and <command>dropdb</command> can
-    be found in <xref linkend="APP-CREATEDB"> and <xref linkend="APP-DROPDB">
+    be found in <xref linkend="app-createdb"> and <xref linkend="app-dropdb">
     respectively.
    </para>
   </sect1>
diff --git a/doc/src/sgml/tablefunc.sgml b/doc/src/sgml/tablefunc.sgml
index 7cfae4d3169..6f1d3df34df 100644
--- a/doc/src/sgml/tablefunc.sgml
+++ b/doc/src/sgml/tablefunc.sgml
@@ -295,7 +295,7 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text);
 
    <note>
     <para>
-     See also the <command><link linkend="APP-PSQL-meta-commands-crosstabview">\crosstabview</link></command>
+     See also the <command><link linkend="app-psql-meta-commands-crosstabview">\crosstabview</link></command>
      command in <application>psql</application>, which provides functionality similar
      to <function>crosstab()</function>.
     </para>
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index b6f33037ff5..d9fccaa17c6 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -3277,10 +3277,10 @@ if (!ptr)
     </para>
    </sect2>
 
-   <sect2 id="extend-Cpp">
+   <sect2 id="extend-cpp">
     <title>Using C++ for Extensibility</title>
 
-    <indexterm zone="extend-Cpp">
+    <indexterm zone="extend-cpp">
      <primary>C++</primary>
     </indexterm>
 
diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml
index 520eab8e99c..dce68dd4ac3 100644
--- a/doc/src/sgml/xindex.sgml
+++ b/doc/src/sgml/xindex.sgml
@@ -470,7 +470,7 @@
   <para>
    GiST indexes have nine support functions, two of which are optional,
    as shown in <xref linkend="xindex-gist-support-table">.
-   (For more information see <xref linkend="GiST">.)
+   (For more information see <xref linkend="gist">.)
   </para>
 
    <table tocentry="1" id="xindex-gist-support-table">
@@ -542,7 +542,7 @@
   <para>
    SP-GiST indexes require five support functions, as
    shown in <xref linkend="xindex-spgist-support-table">.
-   (For more information see <xref linkend="SPGiST">.)
+   (For more information see <xref linkend="spgist">.)
   </para>
 
    <table tocentry="1" id="xindex-spgist-support-table">
@@ -590,7 +590,7 @@
   <para>
    GIN indexes have six support functions, three of which are optional,
    as shown in <xref linkend="xindex-gin-support-table">.
-   (For more information see <xref linkend="GIN">.)
+   (For more information see <xref linkend="gin">.)
   </para>
 
    <table tocentry="1" id="xindex-gin-support-table">
-- 
GitLab