- details.
Acquired by VACUUM (without FULL ),
ANALYZE , CREATE INDEX CONCURRENTLY ,
REINDEX CONCURRENTLY ,
- CREATE STATISTICS , and certain ALTER
- INDEX and ALTER TABLE variants (for full
- details see
and
- linkend="sql-altertable"/>).
+ CREATE STATISTICS , and certain ALTER
+ INDEX and ALTER TABLE variants (for full
+ details see the documentation of these commands).
Acquired by CREATE TRIGGER and some forms of
- <command>ALTER TABLE (see ) .
+ <link linkend="sql-altertable">ALTER TABLE .
Caveats
- Some DDL commands, currently only <xref linkend="sql-truncate"/ > and the
- table-rewriting forms of <xref linkend="sql-altertable"/ >, are not
+ Some DDL commands, currently only <link linkend="sql-truncate">TRUNCATE > and the
+ table-rewriting forms of <link linkend="sql-altertable">ALTER TABLE >, are not
MVCC-safe. This means that after the truncation or rewrite commits, the
table will appear empty to concurrent transactions, if they are using a
snapshot taken before the DDL command committed. This will only be an
plan to match the query structure and the properties of the data
is absolutely critical for good performance, so the system includes
a complex planner that tries to choose good plans.
- You can use the <xref linkend="sql-explain"/ > command
+ You can use the <link linkend="sql-explain">EXPLAIN > command
to see what query plan the planner creates for any query.
Plan-reading is an art that requires some experience to master,
but this section attempts to cover the basics.
Statistics objects are created using the
- <xref linkend="sql-createstatistics"/ > command.
+ <link linkend="sql-createstatistics">CREATE STATISTICS > command.
Creation of such an object merely creates a catalog entry expressing
interest in the statistics. Actual data collection is performed
by ANALYZE (either a manual command, or background
Use COPY
- Use <xref linkend="sql-copy"/ > to load
+ Use <link linkend="sql-copy">COPY > to load
all the rows in one command, instead of using a series of
INSERT commands. The COPY
command is optimized for loading large numbers of rows; it is less
- If you cannot use COPY , it might help to use <xref
- linkend="sql-prepare"/ > to create a
+ If you cannot use COPY , it might help to use <link
+ linkend="sql-prepare">PREPARE > to create a
prepared INSERT statement, and then use
EXECUTE as many times as required. This avoids
some of the overhead of repeatedly parsing and planning
Whenever you have significantly altered the distribution of data
- within a table, running <xref linkend="sql-analyze"/ > is strongly recommended. This
+ within a table, running <link linkend="sql-analyze">ANALYZE > is strongly recommended. This
includes bulk loading large amounts of data into the table. Running
ANALYZE (or VACUUM ANALYZE )
ensures that the planner has up-to-date statistics about the
EXECUTE statement is not related to the
- <xref linkend="sql-execute"/ > SQL
+ <link linkend="sql-execute">EXECUTE > SQL
statement supported by the
PostgreSQL server. The server's
EXECUTE statement cannot be used directly within
Note that constraints other than NOT NULL will never be
imported from the remote tables. Although
PostgreSQL
- does support CHECK constraints on foreign tables, there is no
+ does support check constraints on foreign tables, there is no
provision for importing them automatically, because of the risk that a
constraint expression could evaluate differently on the local and remote
- servers. Any such inconsistency in the behavior of a CHECK
+ servers. Any such inconsistency in the behavior of a check
constraint could lead to hard-to-detect errors in query optimization.
- So if you wish to import CHECK constraints, you must do so
+ So if you wish to import check constraints, you must do so
manually, and you should verify the semantics of each one carefully.
- For more detail about the treatment of CHECK constraints on
+ For more detail about the treatment of check constraints on
foreign tables, see .
Column names must match as well, unless you attach column_name
options to the individual columns to show how they are named in the remote
table.
- In many cases, use of <xref linkend="sql-importforeignschema"/ > is
+ In many cases, use of <link linkend="sql-importforeignschema">IMPORT FOREIGN SCHEMA > is
preferable to constructing foreign table definitions manually.
The process of retrieving or the command to retrieve data from a
database is called a query . In SQL the
- <xref linkend="sql-select"/ > command is
+ <link linkend="sql-select">SELECT > command is
used to specify queries. The general syntax of the
SELECT command is
all the updates made by the transaction to be discarded.
This command is identical
in behavior to the standard
SQL command
- <xref linkend="sql-rollback"/ >,
+ <link linkend="sql-rollback">ROLLBACK >,
and is present only for historical reasons.
If AND CHAIN is specified, a new transaction is
- immediately started with the same transaction characteristics (see <xref
- linkend="sql-set-transaction"/ >) as the just finished one. Otherwise,
+ immediately started with the same transaction characteristics (see <link
+ linkend="sql-set-transaction">SET TRANSACTION >) as the just finished one. Otherwise,
no new transaction is started.
Notes
- Use <xref linkend="sql-commit"/ > to
+ Use <link linkend="sql-commit">COMMIT > to
successfully terminate a transaction.
The recommended syntax for referencing an ordered-set aggregate
is to write ORDER BY between the direct and aggregated
argument specifications, in the same style as in
- <xref linkend="sql-createaggregate"/ >. However, it will also work to
+ <link linkend="sql-createaggregate">CREATE AGGREGATE >. However, it will also work to
omit ORDER BY and just run the direct and aggregated
argument specifications into a single list. In this abbreviated form,
if VARIADIC "any" was used in both the direct and
This form adds a new constraint to a domain using the same syntax as
- <xref linkend="sql-createdomain"/ >.
+ <link linkend="sql-createdomain">CREATE DOMAIN >.
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
This form adds a new column to the foreign table, using the same syntax as
- <xref linkend="sql-createforeigntable"/ >.
+ <link linkend="sql-createforeigntable">CREATE FOREIGN TABLE >.
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.
This form
sets the per-column statistics-gathering target for subsequent
- <xref linkend="sql-analyze"/ > operations.
- See the similar form of <xref linkend="sql-altertable"/ >
+ <link linkend="sql-analyze">ANALYZE > operations.
+ See the similar form of <link linkend="sql-altertable">ALTER TABLE >
for more details.
This form sets or resets per-attribute options.
- See the similar form of <xref linkend="sql-altertable"/ >
+ See the similar form of <link linkend="sql-altertable">ALTER TABLE >
for more details.
This form sets the storage mode for a column.
- See the similar form of <xref linkend="sql-altertable"/ >
+ See the similar form of <link linkend="sql-altertable">ALTER TABLE >
for more details.
Note that the storage mode has no effect unless the table's
foreign-data wrapper chooses to pay attention to it.
This form adds a new constraint to a foreign table, using the same
- syntax as <xref linkend="sql-createforeigntable"/ >.
+ syntax as <link linkend="sql-createforeigntable">CREATE FOREIGN TABLE >.
Currently only CHECK constraints are supported.
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 <link linkend="sql-createforeigntable">CREATE FOREIGN TABLE >.)
If the constraint is marked NOT VALID , then it isn't
assumed to hold, but is only recorded for possible future use.
These forms configure the firing of trigger(s) belonging to the foreign
- table. See the similar form of <xref linkend="sql-altertable"/ > for more
+ table. See the similar form of <link linkend="sql-altertable">ALTER TABLE > for more
details.
This form adds the target foreign table as a new child of the specified
parent table.
- See the similar form of <xref linkend="sql-altertable"/ >
+ See the similar form of <link linkend="sql-altertable">ALTER TABLE >
for more details.
- Refer to <xref linkend="sql-createforeigntable"/ > for a further description of valid
+ Refer to <link linkend="sql-createforeigntable">CREATE FOREIGN TABLE > for a further description of valid
parameters.
group
for this purpose.) These variants are effectively
equivalent to granting or revoking membership in the role named as the
group
; so the preferred way to do this is to use
- <xref linkend="sql-grant"/ > or
- <xref linkend="sql-revoke"/ >.
+ <link linkend="sql-grant">GRANT > or
+ <link linkend="sql-revoke">REVOKE >.
The third variant changes the name of the group. This is exactly
equivalent to renaming the role with
- <xref linkend="sql-alterrole"/ >.
+ <link linkend="sql-alterrole">ALTER ROLE >.
this command, use ALTER DATABASE or explicit
ALTER INDEX invocations instead if desired.
See also
- <xref linkend="sql-createtablespace"/ >.
+ <link linkend="sql-createtablespace">CREATE TABLESPACE >.
This form changes one or more index-method-specific storage parameters
for the index. See
- <xref linkend="sql-createindex"/ >
+ <link linkend="sql-createindex">CREATE INDEX >
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"/ >
+ <link linkend="sql-reindex">REINDEX >
to get the desired effects.
This form sets the per-column statistics-gathering target for
- subsequent <xref linkend="sql-analyze"/ > operations, though can
+ subsequent <link linkend="sql-analyze">ANALYZE > operations, though can
be used only on index columns that are defined as an expression.
Since expressions lack a unique name, we refer to them using the
ordinal number of the index column.
These operations are also possible using
- <xref linkend="sql-altertable"/ >.
+ <link linkend="sql-altertable">ALTER TABLE >.
ALTER INDEX is in fact just an alias for the forms
of ALTER TABLE that apply to indexes.
The statement subforms and actions available for
ALTER MATERIALIZED VIEW are a subset of those available
for ALTER TABLE , and have the same meaning when used for
- materialized views. See the descriptions for
+ materialized views. See the descriptions for
+ ALTER TABLE
for details.
The first variant of this command listed in the synopsis can change
many of the role attributes that can be specified in
- <xref linkend="sql-createrole"/ >.
+ <link linkend="sql-createrole">CREATE ROLE >.
(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.)
+ <link linkend="sql-grant">GRANT > and
+ <link linkend="sql-revoke">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 CREATEROLE privilege can change any of these
default, overriding whatever setting is present in
postgresql.conf or has been received from the postgres
command line. This only happens at login time; executing
- <xref linkend="sql-set-role"/ > or
- <xref linkend="sql-set-session-authorization"/ > does not cause new
+ <link linkend="sql-set-role">SET ROLE > or
+ <link linkend="sql-set-session-authorization">SET SESSION AUTHORIZATION > does not cause new
configuration values to be set.
Settings set for all databases are overridden by database-specific settings
attached to a role. Settings for specific databases or specific roles override
These clauses alter attributes originally set by
- <xref linkend="sql-createrole"/ >. For more information, see the
+ <link linkend="sql-createrole">CREATE ROLE >. For more information, see the
CREATE ROLE reference page.
Role-specific variable settings take effect only at login;
- <xref linkend="sql-set-role"/ > and
- <xref linkend="sql-set-session-authorization"/ >
+ <link linkend="sql-set-role">SET ROLE > and
+ <link linkend="sql-set-session-authorization">SET SESSION AUTHORIZATION >
do not process role-specific variable settings.
Notes
- Use <xref linkend="sql-createrole"/ >
- to add new roles, and <xref linkend="sql-droprole"/ > to remove a role.
+ Use <link linkend="sql-createrole">CREATE ROLE >
+ to add new roles, and <link linkend="sql-droprole">DROP ROLE > to remove a role.
ALTER ROLE cannot change a role's memberships.
- Use <xref linkend="sql-grant"/ > and
- <xref linkend="sql-revoke"/ >
+ Use <link linkend="sql-grant">GRANT > and
+ <link linkend="sql-revoke">REVOKE >
to do that.
The statistic-gathering target for this statistics object for subsequent
- <xref linkend="sql-analyze"/ > operations.
+ <link linkend="sql-analyze">ANALYZE > operations.
The target can be set in the range 0 to 10000; alternatively, set it
to -1 to revert to using the maximum of the statistics target of the
referenced columns, if set, or the system default statistics
This form adds a new column to the table, using the same syntax as
- <xref linkend="sql-createtable"/ >. If IF NOT EXISTS
+ <link linkend="sql-createtable">CREATE TABLE >. If IF NOT EXISTS
is specified and a column already exists with this name,
no error is thrown.
These forms change whether a column is an identity column or change the
generation attribute of an existing identity column.
- See <xref linkend="sql-createtable"/ > for details.
+ See <link linkend="sql-createtable">CREATE TABLE > for details.
Like SET DEFAULT , these forms only affect the
behavior of subsequent INSERT
and UPDATE commands; they do not cause rows
These forms alter the sequence that underlies an existing identity
column. sequence_option is an option
- supported by <xref linkend="sql-altersequence"/ > such
+ supported by <link linkend="sql-altersequence">ALTER SEQUENCE > such
as INCREMENT BY .
This form
sets the per-column statistics-gathering target for subsequent
- <xref linkend="sql-analyze"/ > operations.
+ <link linkend="sql-analyze">ANALYZE > operations.
The target can be set in the range 0 to 10000; alternatively, set it
to -1 to revert to using the system default statistics
target ( ).
defined per-attribute options are n_distinct and
n_distinct_inherited , which override the
number-of-distinct-values estimates made by subsequent
- <xref linkend="sql-analyze"/ >
+ <link linkend="sql-analyze">ANALYZE >
operations. n_distinct affects the statistics for the table
itself, while n_distinct_inherited affects the statistics
gathered for the table plus its inheritance children. When set to a
This form adds a new constraint to a table using the same constraint
- syntax as <xref linkend="sql-createtable"/ >, plus the option NOT
+ syntax as <link linkend="sql-createtable">CREATE TABLE >, plus the option NOT
VALID, which is currently only allowed for foreign key
and CHECK constraints.
Additional restrictions apply when unique or primary key constraints
- are added to partitioned tables; see <xref linkend="sql-createtable"/ >.
+ are added to partitioned tables; see <link linkend="sql-createtable">CREATE TABLE >.
Also, foreign key constraints on partitioned
tables may not be declared NOT VALID at present.
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"/ >.
+ <link linkend="sql-createpolicy">CREATE POLICY >.
disabled (the default) then row level security will not be applied when
the user is the table owner.
See also
- <xref linkend="sql-createpolicy"/ >.
+ <link linkend="sql-createpolicy">CREATE POLICY >.
This form selects the default index for future
- <xref linkend="sql-cluster"/ >
+ <link linkend="sql-cluster">CLUSTER >
operations. It does not actually re-cluster the table.
This form removes the most recently used
- <xref linkend="sql-cluster"/ >
+ <link linkend="sql-cluster">CLUSTER >
index specification from the table. This affects
future cluster operations that don't specify an index.
information_schema relations are not considered part
of the system catalogs and will be moved.
See also
- <xref linkend="sql-createtablespace"/ >.
+ <link linkend="sql-createtablespace">CREATE TABLESPACE >.
This form changes one or more storage parameters for the table. See
in the
- <xref linkend="sql-createtable"/ > documentation
+ <link linkend="sql-createtable">CREATE TABLE > documentation
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 VACUUM
- FULLlink>, > or one of the forms
+ That can be done with VACUUM
+ FULLcommand>, CLUSTER > or one of the forms
of ALTER TABLE 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
A partition using FOR VALUES uses same syntax for
partition_bound_spec as
- <xref linkend="sql-createtable"/ >. The partition bound specification
+ <link linkend="sql-createtable">CREATE TABLE >. The partition bound specification
must correspond to the partitioning strategy and partition key of the
target table. The table to be attached must have all the same columns
as the target table and no more; moreover, the column types must also
The ability to temporarily enable or disable a trigger is provided by
- <xref linkend="sql-altertable"/ >, not by
+ <link linkend="sql-altertable">ALTER TABLE >, not by
ALTER TRIGGER , because ALTER TRIGGER has no
convenient way to express the option of enabling or disabling all of
a table's triggers at once.
This form adds a new attribute to a composite type, using the same syntax as
- <xref linkend="sql-createtype"/ >.
+ <link linkend="sql-createtype">CREATE TYPE >.
ALTER USER is now an alias for
- <xref linkend="sql-alterrole"/ >.
+ <link linkend="sql-alterrole">ALTER ROLE >.
just after making major changes in the contents of a table. Accurate
statistics will help the planner to choose the most appropriate query
plan, and thereby improve the speed of query processing. A common
- strategy for read-mostly databases is to run <xref linkend="sql-vacuum"/ >
+ strategy for read-mostly databases is to run <link linkend="sql-vacuum">VACUUM >
and ANALYZE once a day during a low-usage time of day.
(This will not be sufficient if there is heavy update activity.)
will change slightly each time ANALYZE is run,
even if the actual table contents did not change. This might result
in small changes in the planner's estimated costs shown by
- <xref linkend="sql-explain"/ >.
+ <link linkend="sql-explain">EXPLAIN >.
In rare situations, this non-determinism will cause the planner's
choices of query plans to change after ANALYZE is run.
To avoid this, raise the amount of statistics collected by
The extent of analysis can be controlled by adjusting the
configuration variable, or
on a column-by-column basis by setting the per-column statistics
- target with ALTER TABLE ... ALTER COLUMN ... SET
- STATISTICS (see ) .
+ target with <link linkend="sql-altertable">< command>ALTER TABLE ... ALTER COLUMN ... SET
+ STATISTICS .
The target value sets the
maximum number of entries in the most-common-value list and the
maximum number of bins in the histogram. The default target value
with the largest possible statistics target. If this inaccuracy leads to
bad query plans, a more accurate value can be determined manually and then
installed with
- ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...)
- (see ).
+ ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...) .
BEGIN initiates a transaction block, that is,
all statements after a BEGIN command will be
- executed in a single transaction until an explicit <xref
- linkend="sql-commit"/> or
- linkend="sql-rollback"/ > is given.
+ executed in a single transaction until an explicit <link
+ linkend="sql-commit">COMMIT or
+ linkend="sql-rollback">ROLLBACK > is given.
By default (without BEGIN ),
transactions in autocommit
mode, that is, each
If the isolation level, read/write mode, or deferrable mode is specified, the new
transaction has those characteristics, as if
- <xref linkend="sql-set-transaction"/ >
+ <link linkend="sql-set-transaction">SET TRANSACTION >
was executed.
Notes
- <xref linkend="sql-start-transaction"/ > has the same functionality
+ <link linkend="sql-start-transaction">START TRANSACTION > has the same functionality
as BEGIN .
- Use <xref linkend="sql-commit"/ > or
- <xref linkend="sql-rollback"/ >
+ Use <link linkend="sql-commit">COMMIT > or
+ <link linkend="sql-rollback">ROLLBACK >
to terminate a transaction block.
language extension. It is equivalent to the SQL-standard command
- <xref linkend="sql-start-transaction"/ >, whose reference page
+ <link linkend="sql-start-transaction">START TRANSACTION >, whose reference page
contains additional compatibility information.
PostgreSQL does not have an explicit
OPEN cursor statement; a cursor is considered
open when it is declared. Use the
- <xref linkend="sql-declare"/ >
+ <link linkend="sql-declare">DECLARE >
statement to declare a cursor.
CLUSTER table_name
reclusters the table using the same index as before. You can also
use the CLUSTER or SET WITHOUT CLUSTER
- forms of <xref linkend="sql-altertable"/ > to set the index to be used for
+ forms of <link linkend="sql-altertable">ALTER TABLE > to set the index to be used for
future cluster operations, or to clear any previous setting.
Because the planner records statistics about the ordering of
- tables, it is advisable to run <xref linkend="sql-analyze"/ >
+ tables, it is advisable to run <link linkend="sql-analyze">ANALYZE >
on the newly clustered table.
Otherwise, the planner might make poor choices of query plans.
query
- A , ,
- , or
- command whose results are to be
+ A SELECT ,
+ VALUES ,
+ INSERT ,
+ UPDATE , or
+ DELETE command whose results are to be
copied. Note that parentheses are required around the query.
The meanings of PARALLEL SAFE , PARALLEL
RESTRICTED, and PARALLEL UNSAFE are the same as
- in <xref linkend="sql-createfunction"/ >. An aggregate will not be
+ in <link linkend="sql-createfunction">CREATE FUNCTION >. An aggregate will not be
considered for parallelization if it is marked PARALLEL
UNSAFE (which is the default!) or PARALLEL RESTRICTED .
Note that the parallel-safety markings of the aggregate's support
Notes
- Use <xref linkend="sql-dropcast"/ > to remove user-defined casts.
+ Use <link linkend="sql-dropcast">DROP CAST > to remove user-defined casts.
- Use <xref linkend="sql-dropdatabase"/ > to remove a database.
+ Use <link linkend="sql-dropdatabase">DROP DATABASE > to remove a database.
- Database-level configuration parameters (set via <xref
- linkend="sql-alterdatabase"/ >) and database-level permissions (set via
- <xref linkend="sql-grant"/ >) are not copied from the template database.
+ Database-level configuration parameters (set via <link
+ linkend="sql-alterdatabase">ALTER DATABASE >) and database-level permissions (set via
+ <link linkend="sql-grant">GRANT >) are not copied from the template database.
tables from which the new foreign table automatically inherits
all columns. Parent tables can be plain tables or foreign tables.
See the similar form of
- <xref linkend="sql-createtable"/ > for more details.
+ <link linkend="sql-createtable">CREATE TABLE > for more details.
This form can be used to create the foreign table as partition of
the given parent table with specified partition bound values.
See the similar form of
- <xref linkend="sql-createtable"/ > for more details.
+ <link linkend="sql-createtable">CREATE TABLE > for more details.
Note that it is currently not allowed to create the foreign table as a
partition of the parent table if there are UNIQUE
indexes on the parent table. (See also
the SQL function. The string
class="parameter">obj_file 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 <link linkend="sql-load">LOAD > command. The string
link_symbol 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 to
- Setting a value for parallel_workers via <xref
- linkend="sql-altertable"/ > directly controls how many parallel
+ Setting a value for parallel_workers via <link
+ linkend="sql-altertable">ALTER TABLE > directly controls how many parallel
worker processes will be requested by a CREATE
INDEX against the table. This bypasses the cost model
completely, and prevents maintenance_work_mem
- Use <xref linkend="sql-dropindex"/ >
+ Use <link linkend="sql-dropindex">DROP INDEX >
to remove an index.
name of a previously registered function that will be called
to execute an anonymous code block
- (<xref linkend="sql-do"/ > command)
+ (<link linkend="sql-do">DO > command)
in this language.
If no inline_handler
function is specified, the language does not support anonymous code
Notes
- Use <xref linkend="sql-droplanguage"/ > to drop procedural languages.
+ Use <link linkend="sql-droplanguage">DROP LANGUAGE > to drop procedural languages.
query
- A <xref linkend="sql-select"/>, TABLE ,
- or <xref linkend="sql-values"/ > command. This query will run within a
+ A <link linkend="sql-select">SELECT , TABLE ,
+ or <link linkend="sql-values">VALUES > command. This query will run within a
security-restricted operation; in particular, calls to functions that
themselves create temporary tables will fail.
- Use <xref linkend="sql-dropoperator"/ > to delete user-defined operators
- from a database. Use <xref linkend="sql-alteroperator"/ > to modify operators in a
+ Use <link linkend="sql-dropoperator">DROP OPERATOR > to delete user-defined operators
+ from a database. Use <link linkend="sql-alteroperator">ALTER OPERATOR > to modify operators in a
database.
the SQL procedure. The string
class="parameter">obj_file is the name of the shared
library file containing the compiled C procedure, and is interpreted
- as for the <xref linkend="sql-load"/ > command. The string
+ as for the <link linkend="sql-load">LOAD > command. The string
link_symbol is the
procedure's link symbol, that is, the name of the procedure in the C
language source code. If the link symbol is omitted, it is assumed
If not specified,
NOLOGIN is the default, except when
CREATE ROLE is invoked through its alternative spelling
- <xref linkend="sql-createuser"/ >.
+ <link linkend="sql-createuser">CREATE USER >.
Notes
- Use <xref linkend="sql-alterrole"/ > to
- change the attributes of a role, and <xref linkend="sql-droprole"/ >
+ Use <link linkend="sql-alterrole">ALTER ROLE > to
+ change the attributes of a role, and <link linkend="sql-droprole">DROP ROLE >
to remove a role. All the attributes
specified by CREATE ROLE can be modified by later
ALTER ROLE commands.
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"/ >.
+ <link linkend="sql-grant">GRANT > and
+ <link linkend="sql-revoke">REVOKE >.
a member of a role with CREATEDB privilege does not immediately
grant the ability to create databases, even if INHERIT is set;
it would be necessary to become that role via
- <xref linkend="sql-set-role"/ > before
+ <link linkend="sql-set-role">SET ROLE > before
creating a database.
constraint that is not deferrable will be checked immediately
after every command. Checking of constraints that are
deferrable can be postponed until the end of the transaction
- (using the <xref linkend="sql-set-constraints"/ > command).
+ (using the <link linkend="sql-set-constraints">SET CONSTRAINTS > command).
NOT DEFERRABLE is the default.
Currently, only UNIQUE , PRIMARY KEY ,
EXCLUDE , and
statement. This is the default. If the constraint is
INITIALLY DEFERRED , it is checked only at the
end of the transaction. The constraint check time can be
- altered with the <xref linkend="sql-set-constraints"/ > command.
+ altered with the <link linkend="sql-set-constraints">SET CONSTRAINTS > command.
All rows in the temporary table will be deleted at the end
- of each transaction block. Essentially, an automatic <xref
- linkend="sql-truncate"/ > is done
+ of each transaction block. Essentially, an automatic <link
+ linkend="sql-truncate">TRUNCATE > is done
at each commit. When used on a partitioned table, this
is not cascaded to its partitions.
Disabling index cleanup can speed up VACUUM very
significantly, but may also lead to severely bloated indexes if table
modifications are frequent. The INDEX_CLEANUP
- parameter of <xref linkend="sql-vacuum"/ >, if specified, overrides
+ parameter of <link linkend="sql-vacuum">VACUUM >, if specified, overrides
the value of this option.
the truncated pages is returned to the operating system.
Note that the truncation requires ACCESS EXCLUSIVE
lock on the table. The TRUNCATE parameter
- of <xref linkend="sql-vacuum"/ >, if specified, overrides the value
+ of <link linkend="sql-vacuum">VACUUM >, if specified, overrides the value
of this option.
All rows in the temporary table will be deleted at the end
- of each transaction block. Essentially, an automatic <xref
- linkend="sql-truncate"/ > is done
+ of each transaction block. Essentially, an automatic <link
+ linkend="sql-truncate">TRUNCATE > is done
at each commit.
query
- A <
xref linkend="sql-select"/ >,
- linkend="sql-table">TABLE, or >
- command, or an <xref linkend="sql-execute"/ > command that runs a
+ A <
link linkend="sql-select">SELECT >,
+ linkend="sql-table">TABLE , or VALUES >
+ command, or an <link linkend="sql-execute">EXECUTE > command that runs a
prepared SELECT , TABLE , or
VALUES query.
Notes
- Use <xref linkend="sql-droptransform"/ > to remove transforms.
+ Use <link linkend="sql-droptransform">DROP TRANSFORM > to remove transforms.
When the CONSTRAINT option is specified, this command creates a
constraint trigger . 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"/ >.
+ <link linkend="sql-set-constraints">SET CONSTRAINTS >.
Constraint triggers must be AFTER ROW triggers on plain
tables (not foreign tables). They
can be fired either at the end of the statement causing the triggering
- Use <xref linkend="sql-droptrigger"/ > to remove a trigger.
+ Use <link linkend="sql-droptrigger">DROP TRIGGER > to remove a trigger.
must be less than NAMEDATALEN bytes long (64 bytes in a
standard
PostgreSQL build). (It is possible to
create an enumerated type with zero labels, but such a type cannot be used
- to hold values before at least one label is added using <xref
- linkend="sql-altertype"/ >.)
+ to hold values before at least one label is added using <link
+ linkend="sql-altertype">ALTER TYPE >.)
CREATE USER is now an alias for
- <xref linkend="sql-createrole"/ >.
+ <link linkend="sql-createrole">CREATE ROLE >.
The only difference is that when the command is spelled
CREATE USER , LOGIN is assumed
by default, whereas NOLOGIN is assumed when
This parameter may be either local or
cascaded , and is equivalent to specifying
WITH [ CASCADED | LOCAL ] CHECK OPTION (see below).
- This option can be changed on existing views using <xref
- linkend="sql-alterview"/ >.
+ This option can be changed on existing views using <link
+ linkend="sql-alterview">ALTER VIEW >.
query
- A <xref linkend="sql-select"/ > or
- <xref linkend="sql-values"/ > command
+ A <link linkend="sql-select">SELECT > or
+ <link linkend="sql-values">VALUES > command
which will provide the columns and rows of the view.
Notes
- Use the <xref linkend="sql-dropview"/ >
+ Use the <link linkend="sql-dropview">DROP VIEW >
statement to drop views.
createdb is a wrapper around the
-
SQL command <
xref linkend="sql-createdatabase"/ >.
+
SQL command <
link linkend="sql-createdatabase">CREATE DATABASE >.
There is no effective difference between creating databases via
this utility and via other methods for accessing the server.
The options -D , -l , -E ,
-O , and
-T correspond to options of the underlying
- SQL command <xref linkend="sql-createdatabase"/ >; see there for more information
+ SQL command <link linkend="sql-createdatabase">CREATE DATABASE >; see there for more information
about them.
createuser is a wrapper around the
-
SQL command <
xref linkend="sql-createrole"/ >.
+
SQL command <
link linkend="sql-createrole">CREATE ROLE >.
There is no effective difference between creating users via
this utility and via other methods for accessing the server.
can be used to retrieve
a small number of rows at a time out of a larger query.
After the cursor is created, rows are fetched from it using
- <xref linkend="sql-fetch"/ >.
+ <link linkend="sql-fetch">FETCH >.
query
- A <xref linkend="sql-select"/ > or
- <xref linkend="sql-values"/ > command
+ A <link linkend="sql-select">SELECT > or
+ <link linkend="sql-values">VALUES > command
which will provide the rows to be returned by the cursor.
PostgreSQL reports an error if such a
command is used outside a transaction block.
Use
- <xref linkend="sql-begin"/ > and
- <xref linkend="sql-commit"/ >
- (or <xref linkend="sql-rollback"/ >)
+ <link linkend="sql-begin">BEGIN > and
+ <link linkend="sql-commit">COMMIT >
+ (or <link linkend="sql-rollback">ROLLBACK >)
to define a transaction block.
If the cursor's query includes FOR UPDATE or FOR
SHARE, then returned rows are locked at the time they are first
fetched, in the same way as for a regular
- <xref linkend="sql-select"/ > command with
+ <link linkend="sql-select">SELECT > command with
these options.
In addition, the returned rows will be the most up-to-date versions;
therefore these options provide the equivalent of what the SQL standard
- <xref linkend="sql-truncate"/ > provides a
+ <link linkend="sql-truncate">TRUNCATE > provides a
faster mechanism to remove all rows from a table.
DROP GROUP is now an alias for
- <xref linkend="sql-droprole"/ >.
+ <link linkend="sql-droprole">DROP ROLE >.
As of
PostgreSQL 9.1, most procedural
languages have been made into extensions
, and should
- therefore be removed with <xref linkend="sql-dropextension"/ >
+ therefore be removed with <link linkend="sql-dropextension">DROP EXTENSION >
not DROP LANGUAGE .
- The <xref linkend="sql-reassign-owned"/ > command is an alternative that
+ The <link linkend="sql-reassign-owned">REASSIGN OWNED > command is an alternative that
reassigns the ownership of all the database objects owned by one or
more roles. However, REASSIGN OWNED does not deal with
privileges for other objects.
of the cluster; an error will be raised if so. Before dropping the role,
you must drop all the objects it owns (or reassign their ownership)
and revoke any privileges the role has been granted on other objects.
- The and
+ The REASSIGN
+ OWNED and DROP
+ OWNED
commands can be useful for this purpose; see
for more discussion.
DROP TABLE removes tables from the database.
Only the table owner, the schema owner, and superuser can drop a
table. To empty a table of rows
- without destroying the table, use <xref linkend="sql-delete"/ >
- or <xref linkend="sql-truncate"/ >.
+ without destroying the table, use <link linkend="sql-delete">DELETE >
+ or <link linkend="sql-truncate">TRUNCATE >.
DROP USER is simply an alternate spelling of
- <xref linkend="sql-droprole"/ >.
+ <link linkend="sql-droprole">DROP ROLE >.
dropdb is a wrapper around the
-
SQL command <
xref linkend="sql-dropdatabase"/ >.
+
SQL command <
link linkend="sql-dropdatabase">DROP DATABASE >.
There is no effective difference between dropping databases via
this utility and via other methods for accessing the server.
dropuser is a wrapper around the
-
SQL command <
xref linkend="sql-droprole"/ >.
+
SQL command <
link linkend="sql-droprole">DROP ROLE >.
There is no effective difference between dropping users via
this utility and via other methods for accessing the server.
made by the transaction become visible to others and are guaranteed
to be durable if a crash occurs. This command is a
- that is equivalent to <xref linkend="sql-commit"/ >.
+ that is equivalent to <link linkend="sql-commit">COMMIT >.
Notes
- Use <xref linkend="sql-rollback"/ > to
+ Use <link linkend="sql-rollback">ROLLBACK > to
abort a transaction.
- extension that provides functionality equivalent to <xref
- linkend="sql-commit"/ >, which is
+ extension that provides functionality equivalent to <link
+ linkend="sql-commit">COMMIT >, which is
specified in the SQL standard.
the autovacuum daemon will take care
of that automatically. But if a table has recently had substantial
changes in its contents, you might need to do a manual
- <xref linkend="sql-analyze"/ > rather than wait for autovacuum to catch up
+ <link linkend="sql-analyze">ANALYZE > rather than wait for autovacuum to catch up
with the changes.
- <xref linkend="sql-declare"/ >
+ <link linkend="sql-declare">DECLARE >
is used to define a cursor. Use
- <xref linkend="sql-move"/ >
+ <link linkend="sql-move">MOVE >
to change cursor position without retrieving data.
Notes
- The <xref linkend="sql-revoke"/ > command is used
+ The <link linkend="sql-revoke">REVOKE > command is used
to revoke access privileges.
PostgreSQL reports an error if
LOCK
is used outside a transaction block.
Use
- <xref linkend="sql-begin"/ > and
- <xref linkend="sql-commit"/ >
- (or <xref linkend="sql-rollback"/ >)
+ <link linkend="sql-begin">BEGIN > and
+ <link linkend="sql-commit">COMMIT >
+ (or <link linkend="sql-rollback">ROLLBACK >)
to define a transaction block.
This option is meant for other programs that interact with a server
instance, such as , to query configuration
- parameter values. User-facing applications should instead use <xref
- linkend="sql-show"/ > or the pg_settings view.
+ parameter values. User-facing applications should instead use <link
+ linkend="sql-show">SHOW > or the pg_settings view.
also means that a single prepared statement cannot be used by
multiple simultaneous database clients; however, each client can create
their own prepared statement to use. Prepared statements can be
- manually cleaned up using the <xref linkend="sql-deallocate"/ > command.
+ manually cleaned up using the <link linkend="sql-deallocate">DEALLOCATE > command.
To examine the query plan
PostgreSQL is using
- for a prepared statement, use <xref linkend="sql-explain"/ >, for example
+ for a prepared statement, use <link linkend="sql-explain">EXPLAIN >, for example
EXPLAIN EXECUTE name (parameter_values );
Once prepared, a transaction can later be committed or rolled back
- with <xref linkend="sql-commit-prepared"/ >
- or <xref linkend="sql-rollback-prepared"/ >,
+ with <link linkend="sql-commit-prepared">COMMIT PREPARED >
+ or <link linkend="sql-rollback-prepared">ROLLBACK PREPARED >,
respectively. Those commands can be issued from any session, not
only the one that executed the original transaction.
- This command must be used inside a transaction block. Use <xref
- linkend="sql-begin"/ > to start one.
+ This command must be used inside a transaction block. Use <link
+ linkend="sql-begin">BEGIN > to start one.
Whenever a command is executed,
psql also polls
for asynchronous notification events generated by
- <xref linkend="sql-listen"/ > and
- <xref linkend="sql-notify"/ >.
+ <link linkend="sql-listen">LISTEN > and
+ <link linkend="sql-notify">NOTIFY >.
Performs a frontend (client) copy. This is an operation that
- runs an
SQL <
xref linkend="sql-copy"/ >
+ runs an
SQL <
link linkend="sql-copy">COPY >
command, but instead of the server
reading or writing the specified file,
psql reads or writes the file and
The syntax of this command is similar to that of the
-
SQL <
xref linkend="sql-copy"/ >
+
SQL <
link linkend="sql-copy">COPY >
command. All options other than the data source/destination are
- as specified for <xref linkend="sql-copy"/ >.
+ as specified for <command>COPY>.
Because of this, special parsing rules apply to the \copy
meta-command. Unlike most other meta-commands, the entire remainder
of the line is always taken to be the arguments of \copy ,
- Descriptions for objects can be created with the <xref
- linkend="sql-comment"/ >
+ Descriptions for objects can be created with the <link
+ linkend="sql-comment">COMMENT >
- The <xref linkend="sql-alterdefaultprivileges"/> command is used to set
- default access privileges. The meaning of the
- privilege display is explained in
+ The <link linkend="sql-alterdefaultprivileges">ALTER DEFAULT
+ PRIVILEGES command is used to set default access
+ privileges. The meaning of the privilege display is explained in
.
- The <xref linkend="sql-grant"/ > and
- <xref linkend="sql-revoke"/ >
+ The <link linkend="sql-grant">GRANT > and
+ <link linkend="sql-revoke">REVOKE >
commands are used to set access privileges. The meaning of the
privilege display is explained in
.
- The <xref linkend="sql-alterrole"/ > and
- <xref linkend="sql-alterdatabase"/ >
+ The <link linkend="sql-alterrole">ALTER ROLE > and
+ <link linkend="sql-alterdatabase">ALTER DATABASE >
commands are used to define per-role and per-database configuration
settings.
This command is unrelated to the
SQL
- command <xref linkend="sql-set"/ >.
+ command <link linkend="sql-set">SET >.
- The <xref linkend="sql-drop-owned"/ > command is an alternative that
+ The <link linkend="sql-drop-owned">DROP OWNED > command is an alternative that
simply drops all the database objects owned by one or more roles.
While the default index for future
- <xref linkend="sql-cluster"/ >
+ <link linkend="sql-cluster">CLUSTER >
operations is retained, REFRESH MATERIALIZED VIEW does not
order the generated rows based on this property. If you want the data
to be ordered upon generation, you must use an ORDER BY
reindexdb is a wrapper around the SQL
- command <xref linkend="sql-reindex"/ >.
+ command <link linkend="sql-reindex">REINDEX >.
There is no effective difference between reindexing databases via
this utility and via other methods for accessing the server.
- See the description of the <xref linkend="sql-grant"/ > command for
+ See the description of the <link linkend="sql-grant">GRANT > command for
the meaning of the privilege types.
Compatibility
- The compatibility notes of the <xref linkend="sql-grant"/ > command
+ The compatibility notes of the <link linkend="sql-grant">GRANT > command
apply analogously to REVOKE .
The keyword RESTRICT or CASCADE
is required according to the standard, but
PostgreSQL
Notes
- Use <xref linkend="sql-commit"/ > to
+ Use <link linkend="sql-commit">COMMIT > to
successfully terminate a transaction.
Notes
- Use <xref linkend="sql-release-savepoint"/ > to destroy a savepoint
+ Use <link linkend="sql-release-savepoint">RELEASE SAVEPOINT > to destroy a savepoint
without discarding the effects of commands executed after it was
established.
Notes
- Use <xref linkend="sql-rollback-to"/ > to
- rollback to a savepoint. Use <xref linkend="sql-release-savepoint"/ >
+ Use <link linkend="sql-rollback-to">ROLLBACK TO > to
+ rollback to a savepoint. Use <link linkend="sql-release-savepoint">RELEASE SAVEPOINT >
to destroy a savepoint, keeping
the effects of commands executed after it was established.
sub-SELECT must be surrounded by
parentheses, and an alias must be
provided for it. A
- <xref linkend="sql-values"/ > command
+ <link linkend="sql-values">VALUES > command
can also be used here.
to the row-level lock(s) — the required ROW SHARE
table-level lock is still taken in the ordinary way (see
). You can use
- <xref linkend="sql-lock"/ >
+ <link linkend="sql-lock">LOCK >
with the NOWAIT option first,
if you need to acquire the table-level lock without waiting.
Notes
- <xref linkend="sql-createtableas"/ > is functionally similar to
+ <link linkend="sql-createtableas">CREATE TABLE AS > is functionally similar to
SELECT INTO . CREATE TABLE AS
is the recommended syntax, since this form of SELECT
INTO is not available in
ECPG
In contrast to CREATE TABLE AS , SELECT
INTO does not allow to specify properties like a table's access
method with or the table's
- tablespace with . Use
- linkend="sql-createtableas"/ > if necessary. Therefore, the default table
+ tablespace with . Use
+ CREATE TABLE AS > if necessary. Therefore, the default table
access method is chosen for the new table. See
linkend="guc-default-table-access-method"/> for more information.
The SESSION and LOCAL modifiers act the same
- as for the regular <xref linkend="sql-set"/ >
+ as for the regular <link linkend="sql-set">SET >
command.
SET ROLE has effects comparable to
- <xref linkend="sql-set-session-authorization"/ >, but the privilege
+ <link linkend="sql-set-session-authorization">SET SESSION AUTHORIZATION >, but the privilege
checks involved are quite different. Also,
SET SESSION AUTHORIZATION determines which roles are
allowable for later SET ROLE commands, whereas changing
SET ROLE does not process session variables as specified by
- the role's <xref linkend="sql-alterrole"/ > settings; this only happens during
+ the role's <link linkend="sql-alterrole">ALTER ROLE > settings; this only happens during
login.
identifier is normally equal to the session user identifier, but
might change temporarily in the context of SECURITY DEFINER
functions and similar mechanisms; it can also be changed by
- <xref linkend="sql-set-role"/ >.
+ <link linkend="sql-set-role">SET ROLE >.
The current user identifier is relevant for permission checking.
The SESSION and LOCAL modifiers act the same
- as for the regular <xref linkend="sql-set"/ >
+ as for the regular <link linkend="sql-set">SET >
command.
This command begins a new transaction block. If the isolation level,
read/write mode, or deferrable mode is specified, the new transaction has those
- characteristics, as if <xref linkend="sql-set-transaction"/ > was executed. This is the same
- as the <xref linkend="sql-begin"/ > command.
+ characteristics, as if <link linkend="sql-set-transaction">SET TRANSACTION > was executed. This is the same
+ as the <link linkend="sql-begin">BEGIN > command.
vacuumdb is a wrapper around the SQL
- command <xref linkend="sql-vacuum"/ >.
+ command <link linkend="sql-vacuum">VACUUM >.
There is no effective difference between vacuuming and analyzing
databases via this utility and via other methods for accessing the
server.
- The <xref linkend="sql-security-label"/ > statement allows assignment of
+ The <link linkend="sql-security-label">SECURITY LABEL > statement allows assignment of
a security label to a database object.
- <xref linkend="sql-createdatabase"/ > additionally requires
+ <link linkend="sql-createdatabase">CREATE DATABASE > additionally requires
getattr permission for the source or template database.
- Using <xref linkend="sql-security-label"/ > on an object additionally
+ Using <link linkend="sql-security-label">SECURITY LABEL > on an object additionally
requires relabelfrom permission for the object in
conjunction with its old security label and relabelto
permission for the object in conjunction with its new security label.
Miscellaneous
- We reject the <xref linkend="sql-load"/ > command across the board, because
+ We reject the <link linkend="sql-load">LOAD > command across the board, because
any module loaded could easily circumvent security policy enforcement.
The tsm_system_rows module provides the table sampling method
SYSTEM_ROWS , which can be used in
- the TABLESAMPLE clause of a <xref linkend="sql-select"/ >
+ the TABLESAMPLE clause of a <link linkend="sql-select">SELECT >
command.
The tsm_system_time module provides the table sampling method
SYSTEM_TIME , which can be used in
- the TABLESAMPLE clause of a <xref linkend="sql-select"/ >
+ the TABLESAMPLE clause of a <link linkend="sql-select">SELECT >
command.
operating system users. In practice it might be convenient to
maintain a correspondence, but this is not required. Database roles
are global across a database cluster installation (and not
- per individual database). To create a role use the <xref
- linkend="sql-createrole"/ > SQL command:
+ per individual database). To create a role use the <link
+ linkend="sql-createrole">CREATE ROLE > SQL command:
CREATE ROLE name ;
double-quoted. (In practice, you will usually want to add additional
options, such as LOGIN , to the command. More details appear
below.) To remove an existing role, use the analogous
- <xref linkend="sql-droprole"/ > command:
+ <link linkend="sql-droprole">DROP ROLE > command:
DROP ROLE name ;
Once the group role exists, you can add and remove members using the
- <xref linkend="sql-grant"/ > and
- <xref linkend="sql-revoke"/ > commands:
+ <link linkend="sql-grant">GRANT > and
+ <link linkend="sql-revoke">REVOKE > commands:
GRANT group_role TO role1 , ... ;
REVOKE group_role FROM role1 , ... ;
The members of a group role can use the privileges of the role in two
ways. First, every member of a group can explicitly do
- <xref linkend="sql-set-role"/ > to
+ <link linkend="sql-set-role">SET ROLE > to
temporarily become
the group role. In this state, the
database session has access to the privileges of the group role rather
than the original login role, and any database objects created are
- To destroy a group role, use <xref
- linkend="sql-droprole"/ >:
+ To destroy a group role, use <link
+ linkend="sql-droprole">DROP ROLE >:
DROP ROLE name ;
Because roles can own database objects and can hold privileges
to access other objects, dropping a role is often not just a matter of a
- quick <xref linkend="sql-droprole"/ >. Any objects owned by the role must
+ quick <link linkend="sql-droprole">DROP ROLE >. Any objects owned by the role must
first be dropped or reassigned to other owners; and any permissions
granted to the role must be revoked.
ALTER TABLE bobs_table OWNER TO alice;
- Alternatively, the <xref linkend="sql-reassign-owned"/ > command can be
+ Alternatively, the <link linkend="sql-reassign-owned">REASSIGN OWNED > command can be
used to reassign ownership of all objects owned by the role-to-be-dropped
to a single other role. Because REASSIGN OWNED cannot access
objects in other databases, it is necessary to run it in each database
Once any valuable objects have been transferred to new owners, any
remaining objects owned by the role-to-be-dropped can be dropped with
- the <xref linkend="sql-drop-owned"/ > command. Again, this command cannot
+ the <link linkend="sql-drop-owned">DROP OWNED > command. Again, this command cannot
access objects in other databases, so it is necessary to run it in each
database that contains objects owned by the role. Also, DROP
OWNED will not drop entire databases or tablespaces, so it is
Administrators can grant access to these roles to users using the
- <xref linkend="sql-grant"/ > command, for example:
+ <link linkend="sql-grant">GRANT > command, for example:
GRANT pg_signal_backend TO admin_user;
Also, because the final function performs the sort, it is not possible
to continue adding input rows by executing the transition function again
later. This means the final function is not READ_ONLY ;
- it must be declared in <xref linkend="sql-createaggregate"/ >
+ it must be declared in <link linkend="sql-createaggregate">CREATE AGGREGATE >
as READ_WRITE , or as SHAREABLE if
it's possible for additional final-function calls to make use of the
already-sorted state.
that a procedure does not return a value, so there is no return type
declaration. While a function is called as part of a query or DML
command, a procedure is called in isolation using
- the <xref linkend="sql-call"/> command. If the CALL command is not
+ the <link linkend="sql-call">CALL command. If the CALL command is not
part of an explicit transaction, a procedure in many server-side
languages can commit, rollback, and begin new transactions during
its execution, which is not possible in functions.
The explanations on how to define user-defined functions in the rest of
this chapter apply to procedures as well, except that
- the <xref linkend="sql-createprocedure"/ > command is used instead, there is
+ the <link linkend="sql-createprocedure">CREATE PROCEDURE > command is used instead, there is
no return type, and some other features such as strictness don't apply.
Collectively, functions and procedures are also known
- There are commands such as <xref linkend="sql-alterroutine"/ >
- and <xref linkend="sql-droproutine"/ > that can operate on functions and
+ There are commands such as <link linkend="sql-alterroutine">ALTER ROUTINE >
+ and <link linkend="sql-droproutine">DROP ROUTINE > that can operate on functions and
procedures without having to know which kind it is. Note, however, that
there is no CREATE ROUTINE command.
Every function has a volatility classification, with
the possibilities being VOLATILE , STABLE , or
IMMUTABLE . VOLATILE is the default if the
- <xref linkend="sql-createfunction"/ >
+ <link linkend="sql-createfunction">CREATE FUNCTION >
command does not specify a category. The volatility category is a
promise to the optimizer about the behavior of the function:
Some basic facts can be supplied by declarative annotations provided in
- the <xref linkend="sql-createfunction"/ > command. Most important of
+ the <link linkend="sql-createfunction">CREATE FUNCTION > command. Most important of
these is the function's volatility
category (IMMUTABLE , STABLE ,
or VOLATILE ); one should always be careful to
Optionally, the language handler can provide an inline
handler function that executes anonymous code blocks
- (<xref linkend="sql-do"/ > commands)
+ (<link linkend="sql-do">DO > commands)
written in this language. If an inline handler function
is provided by the language, declare it with a command like