Managing Databases

A database is a named collection of SQL objects ("database objects"). Generally, every database object (tables, functions, etc.) belongs to one and only one database. (However there are a few system catalogs, for example pg_database, that belong to a whole cluster and are accessible from each database within the cluster.) More accurately, a database is a collection of schemas and the schemas contain the tables, functions, etc. So the full hierarchy is: server, database, schema, table (or some o

Concurrency Control

PostgreSQL provides a rich set of tools for developers to manage concurrent access to data. Internally, data consistency is maintained by using a multiversion model (Multiversion Concurrency Control, MVCC). This means that each SQL statement sees a snapshot of data (a database version) as it was some time ago, regardless of the current state of the underlying data. This prevents statements from viewing inconsistent data produced by concurrent transactions performing updates on the same data row

CREATE COLLATION

NameCREATE COLLATION -- define a new collation Synopsis CREATE COLLATION name ( [ LOCALE = locale, ] [ LC_COLLATE = lc_collate, ] [ LC_CTYPE = lc_ctype ] ) CREATE COLLATION name FROM existing_collation Description CREATE COLLATION defines a new collation using the specified operating system locale settings, or by copying an existing collation. To be able to create a collation, you must have CREATE privilege on the destination schema. Parameters name The name of the co

DROP TABLE

NameDROP TABLE -- remove a table Synopsis DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ] Description 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 DELETE or TRUNCATE. DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. However, to drop a table that is referenced by a view or a foreign-key co

pg_prewarm

The pg_prewarm module provides a convenient way to load relation data into either the operating system buffer cache or the PostgreSQL buffer cache. F.27.1. Functions pg_prewarm(regclass, mode text default 'buffer', fork text default 'main', first_block int8 default null, last_block int8 default null) RETURNS int8 The first argument is the relation to be prewarmed. The second argument is the prewarming method to be used, as further discussed below; the third is the relat

Catalogs: pg_group

The view pg_group exists for backwards compatibility: it emulates a catalog that existed in PostgreSQL before version 8.1. It shows the names and members of all roles that are marked as not rolcanlogin, which is an approximation to the set of roles that are being used as groups. Table 50-64. pg_group Columns Name Type References Description groname name pg_authid.rolname Name of the group grosysid oid pg_authid.oid ID of this group grolist oid[] pg_authid.oid An array containing the IDs of th

END

NameEND -- commit the current transaction Synopsis END [ WORK | TRANSACTION ] Description END commits the current transaction. All changes made by the transaction become visible to others and are guaranteed to be durable if a crash occurs. This command is a PostgreSQL extension that is equivalent to COMMIT. Parameters WORKTRANSACTION Optional key words. They have no effect. Notes Use ROLLBACK to abort a transaction. Issuing END when not inside a transaction does no harm, b

Hot Standby

Hot Standby is the term used to describe the ability to connect to the server and run read-only queries while the server is in archive recovery or standby mode. This is useful both for replication purposes and for restoring a backup to a desired state with great precision. The term Hot Standby also refers to the ability of the server to move from recovery through to normal operation while users continue running queries and/or keep their connections open. Running queries in hot standby mode is s

CREATE TEXT SEARCH PARSER

NameCREATE TEXT SEARCH PARSER -- define a new text search parser Synopsis CREATE TEXT SEARCH PARSER name ( START = start_function , GETTOKEN = gettoken_function , END = end_function , LEXTYPES = lextypes_function [, HEADLINE = headline_function ] ) Description CREATE TEXT SEARCH PARSER creates a new text search parser. A text search parser defines a method for splitting a text string into tokens and assigning types (categories) to the tokens. A parser is not partic

Privileges

When an object is created, it is assigned an owner. The owner is normally the role that executed the creation statement. For most kinds of objects, the initial state is that only the owner (or a superuser) can do anything with the object. To allow other roles to use it, privileges must be granted. There are different kinds of privileges: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, and USAGE. The privileges applicable to a particular object