Enumerated Types

Enumerated (enum) types are data types that comprise a static, ordered set of values. They are equivalent to the enum types supported in a number of programming languages. An example of an enum type might be the days of the week, or a set of status values for a piece of data. 8.7.1. Declaration of Enumerated Types Enum types are created using the CREATE TYPE command, for example: CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); Once created, the enum type can be used in table and function de

Enum Functions

For enum types (described in Section 8.7), there are several functions that allow cleaner programming without hard-coding particular values of an enum type. These are listed in Table 9-32. The examples assume an enum type created as: CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple'); Table 9-32. Enum Support Functions Function Description Example Example Result enum_first(anyenum) Returns the first value of the input enum type enum_first(null::rainbow) red e

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

Encryption Options

PostgreSQL offers encryption at several levels, and provides flexibility in protecting data from disclosure due to database server theft, unscrupulous administrators, and insecure networks. Encryption might also be required to secure sensitive data such as medical records or financial transactions. Password Storage Encryption By default, database user passwords are stored as MD5 hashes, so the administrator cannot determine the actual password assigned to the user. If MD5 encryption is used f

ecpg

Name ecpg -- embedded SQL C preprocessor Synopsis ecpg [option...] file... Description ecpg is the embedded SQL preprocessor for C programs. It converts C programs with embedded SQL statements to normal C code by replacing the SQL invocations with special function calls. The output files can then be processed with any C compiler tool chain. ecpg will convert each input file given on the command line to the corresponding C output file. Input files preferably have the extension .pgc, in w

earthdistance

The earthdistance module provides two different approaches to calculating great circle distances on the surface of the Earth. The one described first depends on the cube module (which must be installed before earthdistance can be installed). The second one is based on the built-in point data type, using longitude and latitude for the coordinates. In this module, the Earth is assumed to be perfectly spherical. (If that's too inaccurate for you, you might want to look at the PostGIS project.) F.

dropuser

Namedropuser -- remove a PostgreSQL user account Synopsis dropuser [connection-option...] [option...] [username] Description dropuser removes an existing PostgreSQL user. Only superusers and users with the CREATEROLE privilege can remove PostgreSQL users. (To remove a superuser, you must yourself be a superuser.) dropuser is a wrapper around the SQL command DROP ROLE. There is no effective difference between dropping users via this utility and via other methods for accessing the server.

Dropping Roles

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 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. Ownership of objects can be transferred one at a time using ALTER commands, for example: ALTER TABLE bobs_table OWNER TO alice; Alternatively, the REASSIGN OWNED command can be used to reassign ownership

droplang

Namedroplang -- remove a PostgreSQL procedural language Synopsis droplang [connection-option...] langname [dbname] droplang [connection-option...] --list | -l [dbname] Description droplang is a utility for removing an existing procedural language from a PostgreSQL database. droplang is just a wrapper around the DROP EXTENSION SQL command. Caution: droplang is deprecated and may be removed in a future PostgreSQL release. Direct use of the DROP EXTENSION command is recommended instead.

dropdb

Namedropdb -- remove a PostgreSQL database Synopsis dropdb [connection-option...] [option...] dbname Description dropdb destroys an existing PostgreSQL database. The user who executes this command must be a database superuser or the owner of the database. dropdb is a wrapper around the SQL command DROP DATABASE. There is no effective difference between dropping databases via this utility and via other methods for accessing the server. Options dropdb accepts the following command-line