PostgreSQL[Encyclopedia]

本文介绍了PostgreSQL数据库管理系统的特点和功能,包括支持多种编程语言的函数、灵活的索引选项、触发器、多版本并发控制等高级特性,并概述了其发展历程及主要应用。
 

PostgreSQL

From Wikipedia, the free encyclopedia

Jump to: navigation, search
PostgreSQL

Maintainer:PostgreSQL Global Development Group
Latest release:8.1.5 / October 16, 2006
OS:Cross-platform
Use:RDBMS
License:BSD
Website:www.postgresql.org

PostgreSQL is a free object-relational database server (database management system), released under a flexible BSD-style license. It offers an alternative to other database systems. Similar to other open-source projects such as Apache, Linux, and Mediawiki, PostgreSQL is not controlled by any single company, but relies on a global community of developers and companies to develop it.

PostgreSQL's unusual-looking name makes some readers pause when trying to pronounce it, especially those who pronounce SQL as "sequel". PostgreSQL's developers pronounce it "post-gress-Q-L". (Audio sample, 5.6k MP3). It is also common to hear it abbreviated as simply "postgres", which was its original name. The name refers to the project's origins as a "post-Ingres" database, the original authors having also developed Ingres.

Contents

[hide]

[edit] Features

[edit] Functions

Functions allow blocks of code to be executed by the server. Although these blocks can be written in SQL, the lack of basic programming operations, such as branching and looping, has driven the adoption of other languages inside of functions. Some of the languages can even execute inside of triggers. Functions in PostgreSQL can be written in the following languages:

Functions can be defined to execute with the privileges of either the caller or the user who defined the function. Functions are sometimes referred to as stored procedures, although there is a slight technical distinction between the two.

[edit] Indexes

User-defined indexes can be created, or the built-in B-tree, hash and GiST indices can be used. Indexes in PostgreSQL also support the following features:

  • PostgreSQL is capable of scanning indexes backwards when needed; you never need a separate index to support ORDER BY field DESC.
  • Expressional indexes can be created with an index of the result of an expression or function, instead of simply the value of a column.
  • Partial indexes, which only index part of a table, can be created by adding a WHERE clause to the end of the CREATE INDEX statement. This allows a smaller index to be created.
  • Bitmap index scans are supported as of version 8.1. This involves reading multiple indexes and generating a bitmap that expresses their intersection with the tuples that match the selection criteria. This provides a way of composing indexes together; on a table with 20 columns, there are, in principle, 20! indexes that could be defined - which is far too many to actually use. If you create one index on each column, bitmap scans can compose arbitrary combinations of those indexes at query time for each column that seems worth considering as a constraint.

[edit] Triggers

Triggers are fully supported and can be attached to tables but not to views. Views can have rules, though. Multiple triggers are fired in alphabetical order. In addition to calling functions written in the native PL/PgSQL, triggers can also invoke functions written in other languages like PL/Perl.

[edit] MVCC

PostgreSQL manages concurrency through a system known as Multi-Version Concurrency Control (MVCC), which gives each user a "snapshot" of the database, allowing changes to be made without being visible to other users until a transaction is committed. This largely eliminates the need for read locks, and ensures the database maintains the ACID principles in an efficient manner.

[edit] Rules

Rules allow the "query tree" of an incoming query to be rewritten. One common usage is to implement updatable views.

[edit] Data types

A wide variety of native data types are supported, including:

In addition, users can create their own data types which can usually be made fully indexable via PostgreSQL's GiST infrastructure.

Examples of these are the Geographic information system (GIS) data types from the PostGIS project for PostgreSQL.

[edit] User-defined objects

New types of almost all objects inside the database can be created, including:

  • Indices
  • Operators (and existing ones can be overloaded)
  • Aggregates
  • Domains
  • Casts
  • Conversions

[edit] Inheritance

Tables can be set to inherit their characteristics from a "parent" table. Data is shared between "parent" and "child(ren)" tables. Tuples inserted or deleted in the "child" table will respectively be inserted or deleted in the "parent" table. Also adding a column in the parent table will cause that column to appear in the child table as well. This feature is not fully supported yet -- in particular, table constraints are not currently inheritable. This means that attempting to insert the id of a row from a child table into table that has a foreign key constraint referencing a parent table will fail because postgres doesn't recognize that the id from the child table is also a valid id in the parent table.

Inheritance provides a way to map the features of generalization hierarchies depicted in Entity Relationship Diagrams (ERD) directly into the PostgreSQL database.

[edit] Other features

[edit] Add-ons

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值