SQL Key Words

Table C-1 lists all tokens that are key words in the SQL standard and in PostgreSQL 9.6.0. Background information can be found in Section 4.1.1. (For space reasons, only the latest two versions of the SQL standard, and SQL-92 for historical comparison, are included. The differences between those and the other intermediate standard versions are small.) SQL distinguishes between reserved and non-reserved key words. According to the standard, reserved key words are the only real key words; they ar

sslinfo

The sslinfo module provides information about the SSL certificate that the current client provided when connecting to PostgreSQL. The module is useless (most functions will return NULL) if the current connection does not use SSL. This extension won't build at all unless the installation was configured with --with-openssl. F.37.1. Functions Provided ssl_is_used() returns boolean Returns TRUE if current connection to server uses SSL, and FALSE otherwise. ssl_version() returns

Shutting Down the Server

There are several ways to shut down the database server. You control the type of shutdown by sending different signals to the master postgres process. SIGTERM This is the Smart Shutdown mode. After receiving SIGTERM, the server disallows new connections, but lets existing sessions end their work normally. It shuts down only after all of the sessions terminate. If the server is in online backup mode, it additionally waits until online backup mode is no longer active. While backup mode is activ

SET TRANSACTION

NameSET TRANSACTION -- set the characteristics of the current transaction Synopsis SET TRANSACTION transaction_mode [, ...] SET TRANSACTION SNAPSHOT snapshot_id SET SESSION CHARACTERISTICS AS TRANSACTION transaction_mode [, ...] where transaction_mode is one of: ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED } READ WRITE | READ ONLY [ NOT ] DEFERRABLE Description The SET TRANSACTION command sets the characteristics of the current tra

SQL Dump

The idea behind this dump method is to generate a file with SQL commands that, when fed back to the server, will recreate the database in the same state as it was at the time of the dump. PostgreSQL provides the utility program pg_dump for this purpose. The basic usage of this command is: pg_dump dbname > outfile As you see, pg_dump writes its result to the standard output. We will see below how this can be useful. While the above command creates a text file, pg_dump can create files in ot

spi

The spi module provides several workable examples of using SPI and triggers. While these functions are of some value in their own right, they are even more useful as examples to modify for your own purposes. The functions are general enough to be used with any table, but you have to specify table and field names (as described below) while creating a trigger. Each of the groups of functions described below is provided as a separately-installable extension. F.36.1. refint — Functions for Impleme

SHOW

NameSHOW -- show the value of a run-time parameter Synopsis SHOW name SHOW ALL Description SHOW will display the current setting of run-time parameters. These variables can be set using the SET statement, by editing the postgresql.conf configuration file, through the PGOPTIONS environmental variable (when using libpq or a libpq-based application), or through command-line flags when starting the postgres server. See Chapter 19 for details. Parameters name The name of a run-time pa

Set Returning Functions

This section describes functions that possibly return more than one row. The most widely used functions in this class are series generating functions, as detailed in Table 9-57 and Table 9-58. Other, more specialized set-returning functions are described elsewhere in this manual. See Section 7.2.1.4 for ways to combine multiple set-returning functions. Table 9-57. Series Generating Functions Function Argument Type Return Type Description generate_series(start, stop) int, bigint or numeric

SET CONSTRAINTS

NameSET CONSTRAINTS -- set constraint check timing for the current transaction Synopsis SET CONSTRAINTS { ALL | name [, ...] } { DEFERRED | IMMEDIATE } Description SET CONSTRAINTS sets the behavior of constraint checking within the current transaction. IMMEDIATE constraints are checked at the end of each statement. DEFERRED constraints are not checked until transaction commit. Each constraint has its own IMMEDIATE or DEFERRED mode. Upon creation, a constraint is given one of three cha

SET ROLE

NameSET ROLE -- set the current user identifier of the current session Synopsis SET [ SESSION | LOCAL ] ROLE role_name SET [ SESSION | LOCAL ] ROLE NONE RESET ROLE Description This command sets the current user identifier of the current SQL session to be role_name. The role name can be written as either an identifier or a string literal. After SET ROLE, permissions checking for SQL commands is carried out as though the named role were the one that had logged in originally. The specifi