Combining Queries

The results of two queries can be combined using the set operations union, intersection, and difference. The syntax is query1 UNION [ALL] query2 query1 INTERSECT [ALL] query2 query1 EXCEPT [ALL] query2 query1 and query2 are queries that can use any of the features discussed up to this point. Set operations can also be nested and chained, for example query1 UNION query2 UNION query3 which is executed as: (query1 UNION query2) UNION query3 UNION effectively appends the result of query2 to t

ABORT

NameABORT -- abort the current transaction Synopsis ABORT [ WORK | TRANSACTION ] Description ABORT rolls back the current transaction and causes all the updates made by the transaction to be discarded. This command is identical in behavior to the standard SQL command ROLLBACK, and is present only for historical reasons. Parameters WORKTRANSACTION Optional key words. They have no effect. Notes Use COMMIT to successfully terminate a transaction. Issuing ABORT outside of a tr

DROP TRIGGER

NameDROP TRIGGER -- remove a trigger Synopsis DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ] Description DROP TRIGGER removes an existing trigger definition. To execute this command, the current user must be the owner of the table for which the trigger is defined. Parameters IF EXISTS Do not throw an error if the trigger does not exist. A notice is issued in this case. name The name of the trigger to remove. table_name The name (optionally schema-qualifi

ALTER CONVERSION

NameALTER CONVERSION -- change the definition of a conversion Synopsis ALTER CONVERSION name RENAME TO new_name ALTER CONVERSION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER } ALTER CONVERSION name SET SCHEMA new_schema Description ALTER CONVERSION changes the definition of a conversion. You must own the conversion to use ALTER CONVERSION. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the

ALTER POLICY

NameALTER POLICY -- change the definition of a row level security policy Synopsis ALTER POLICY name ON table_name RENAME TO new_name ALTER POLICY name ON table_name [ TO { role_name | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ] [ USING ( using_expression ) ] [ WITH CHECK ( check_expression ) ] Description ALTER POLICY changes the definition of an existing row-level security policy. To use ALTER POLICY, you must own the table that the policy applies to. In the second

CHECKPOINT

NameCHECKPOINT -- force a transaction log checkpoint Synopsis CHECKPOINT Description A checkpoint is a point in the transaction log sequence at which all data files have been updated to reflect the information in the log. All data files will be flushed to disk. Refer to Section 30.4 for more details about what happens during a checkpoint. The CHECKPOINT command forces an immediate checkpoint when the command is issued, without waiting for a regular checkpoint scheduled by the system (

Catalogs: pg_prepared_statements

The pg_prepared_statements view displays all the prepared statements that are available in the current session. See PREPARE for more information about prepared statements. pg_prepared_statements contains one row for each prepared statement. Rows are added to the view when a new prepared statement is created and removed when a prepared statement is released (for example, via the DEALLOCATE command). Table 50-69. pg_prepared_statements Columns Name Type Description name text The identifier of t

passwordcheck

The passwordcheck module checks users' passwords whenever they are set with CREATE ROLE or ALTER ROLE. If a password is considered too weak, it will be rejected and the command will terminate with an error. To enable this module, add '$libdir/passwordcheck' to shared_preload_libraries in postgresql.conf, then restart the server. You can adapt this module to your needs by changing the source code. For example, you can use CrackLib to check passwords — this only requires uncommenting two lines in

Catalogs: pg_rewrite

The catalog pg_rewrite stores rewrite rules for tables and views. Table 50-41. pg_rewrite Columns Name Type References Description oid oid Row identifier (hidden attribute; must be explicitly selected) rulename name Rule name ev_class oid pg_class.oid The table this rule is for ev_type char Event type that the rule is for: 1 = SELECT, 2 = UPDATE, 3 = INSERT, 4 = DELETE ev_enabled char Controls in which session_replication_role modes the rule fires. O = rule fires in "origin" and "lo

Catalogs: pg_indexes

The view pg_indexes provides access to useful information about each index in the database. Table 50-65. pg_indexes Columns Name Type References Description schemaname name pg_namespace.nspname Name of schema containing table and index tablename name pg_class.relname Name of table the index is for indexname name pg_class.relname Name of index tablespace name pg_tablespace.spcname Name of tablespace containing index (null if default for database) indexdef text Index definition (a reconstruct