SQLite
SQLite
SQLite uses a dynamically- and weakly-typed SQL syntax that does not guarantee
the domain integrity, which gives rise to criticism. SQLite is a multitasking
database concerning reads. Writes can be done only one-at-a-time. It is a popular
choice for local/client storage on Web browsers. It has many bindings to
programming languages. Before a new version is released, excessive regression
tests are performed, increasing the quality of the product. It is probably the most
widely used database engine, as it is used today by every instance of several
widespread browsers, operating systems, embeded systems among others.[6]
Design
History
D. Richard Hipp designed SQLite in the spring of 2000 while working for General
Dynamics on contract with the United States Navy.[7] Hipp was designing software
used on board guided missile destroyer ships, which were originally based on HP-
UX with an IBM Informix database back-end. The design goals of SQLite were to
allow the program to be operated without database installation or administration.
In August 2000, version 1.0 of SQLite was released, based on gdbm (GNU
Database Manager). SQLite 2.0 replaced gdbm with a custom B-tree
implementation, adding support for transactions. SQLite 3.0, partially funded by
America Online, added internationalization, manifest typing, and other major
improvements.
Features
SQLite implements most of the SQL-92 standard for SQL but it lacks some
features. For example it has partial support for triggers, and it can't write to
views. While it supports complex queries, it still has limited ALTER TABLE support,
as it can't modify or delete columns.[8]
Several computer processes or threads may access the same database without
problems. Several read accesses can be satisfied in parallel. A write access can
only be satisfied, if no other accesses are currently being serviced. Otherwise, the
write access fails with an error code (or can automatically be retried until a
configurable timeout expires). This concurrent access situation would change
when dealing with temporary tables.
A standalone program called sqlite3 is provided that can be used to create a
database, define tables within it, insert and change rows, run queries and
manage a SQLite database file. This program is a single executable file on the
host machine. It also serves as an example for writing applications that use the
SQLite library.
SQLite is a popular choice for local/client SQL storage within a web browser and
within a rich internet application framework;[10] most notably the leaders in this
area (Google Gears,[11] Adobe AIR,[12] and Firefox[13]) embed SQLite.
SQLite also has bindings for a large number of programming languages, including
BASIC, C, C++, Clipper, Common Lisp, C#, Curl, Delphi, Haskell, Java, Lua,
newLisp, Objective-C (on Mac OS X and iPhone), OCaml, Perl, PHP, Pike, Python,
[15]
REBOL, R, Ruby,[16] Scheme, Smalltalk, Tcl and Visual Basic. There is also a
COM (ActiveX) wrapper making SQLite accessible on Windows to scripted
languages such as Javascript and VBScript. This adds database capabilities to
HTML Applications (HTA).[17]
SQLite has automated regression testing prior to each release.[18] Over 2 million
tests are run as part of a release's verification. Starting with the August 10, 2009
release of SQLite 3.6.17, SQLite releases have 100% branch test coverage, one
of the components of code coverage.
Development
Adoption
Due to its small size, SQLite is well suited to embedded systems, and is also
included in Apple's iOS (where it is used for the SMS/MMS, Calendar, Call history
and Contacts storage), Symbian OS, Nokia's Maemo, Google's Android, RIM's
BlackBerry, Linux Foundation's MeeGo and Palm's webOS.[23] However, it is also
suitable for desktop operating systems; Apple adopted it as an option in Mac OS
X's Core Data API from the original implementation in Mac OS X 10.4 onwards,
and also for administration of videos and songs on the iPhone.
This page highlights some of the characteristics of SQLite that are unusual and
which make SQLite different from many other SQL database engines.
Zero-Configuration
Other more familiar database engines run great once you get them going. But
doing the initial installation and configuration can be intimidatingly complex.
Serverless
On the other hand, a database engine that uses a server can provide better
protection from bugs in the client application - stray pointers in a client cannot
corrupt memory on the server. And because a server is a single persistent
process, it is able control database access with more precision, allowing for finer
grain locking and better concurrency.
Most SQL database engines are client/server based. Of those that are serverless,
SQLite is the only one that this author knows of that allows multiple applications
to access the same database at the same time.
An SQLite database is a single ordinary disk file that can be located anywhere in
the directory hierarchy. If SQLite can read the disk file then it can read anything
in the database. If the disk file and its directory are writable, then SQLite can
change anything in the database. Database files can easily be copied onto a USB
memory stick or emailed for sharing.
Other SQL database engines tend to store data as a large collection of files. Often
these files are in a standard location that only the database engine itself can
access. This makes the data more secure, but also makes it harder to access.
Some SQL database engines provide the option of writing directly to disk and
bypassing the filesystem all together. This provides added performance, but at
the cost of considerable setup and maintenance complexity.
The SQLite file format is cross-platform. A database file written on one machine
can be copied to and used on a different machine with a different architecture.
Big-endian or little-endian, 32-bit or 64-bit does not matter. All machines use the
same file format. Furthermore, the developers have pledged to keep the file
format stable and backwards compatible, so newer versions of SQLite can read
and write older database files.
Most other SQL database engines require you to dump and restore the database
when moving from one platform to another and often when upgrading to a newer
version of the software.
Compact
When optimized for size, the whole SQLite library with everything enabled is less
than 275KiB in size (as measured on an ix86 using the "size" utility from the GNU
compiler suite.) Unneeded features can be disabled at compile-time to further
reduce the size of the library to under 190KiB if desired.
Most other SQL database engines are much larger than this. IBM boasts that its
recently released CloudScape database engine is "only" a 2MiB jar file - an order
of magnitude larger than SQLite even after it is compressed! Firebird boasts that
its client-side library is only 350KiB. That's 50% larger than SQLite and does not
even contain the database engine. The Berkeley DB library from Oracle is 450KiB
and it omits SQL support, providing the programmer with only simple key/value
pairs.
Manifest typing
Most SQL database engines use static typing. A datatype is associated with each
column in a table and only values of that particular datatype are allowed to be
stored in that column. SQLite relaxes this restriction by using manifest typing. In
manifest typing, the datatype is a property of the value itself, not of the column
in which the value is stored. SQLite thus allows the user to store any value of any
datatype into any column regardless of the declared type of that column. (There
are some exceptions to this rule: An INTEGER PRIMARY KEY column may only
store integers. And SQLite attempts to coerce values into the declared datatype
of the column when it can.)
As far as we can tell, the SQL language specification allows the use of manifest
typing. Nevertheless, most other SQL database engines are statically typed and
so some people feel that the use of manifest typing is a bug in SQLite. But the
authors of SQLite feel very strongly that this is a feature. The use of manifest
typing in SQLite is a deliberate design decision which has proven in practice to
make SQLite more reliable and easier to use, especially when used in combination
with dynamically typed programming languages such as Tcl and Python.
Variable-length records
Most other SQL database engines allocated a fixed amount of disk space for each
row in most tables. They play special tricks for handling BLOBs and CLOBs which
can be of wildly varying length. But for most tables, if you declare a column to be
a VARCHAR(100) then the database engine will allocate 100 bytes of disk space
regardless of how much information you actually store in that column.
SQLite, in contrast, use only the amount of disk space actually needed to store
the information in a row. If you store a single character in a VARCHAR(100)
column, then only a single byte of disk space is consumed. (Actually two bytes -
there is some overhead at the beginning of each column to record its datatype
and length.)
Every SQL database engine compiles each SQL statement into some kind of
internal data structure which is then used to carry out the work of the statement.
But in most SQL engines that internal data structure is a complex web of
interlinked structures and objects. In SQLite, the compiled form of statements is
a short program in a machine-language like representation. Users of the database
can view this virtual machine language by prepending the EXPLAIN keyword to a
query.
The use of a virtual machine in SQLite has been a great benefit to the library's
development. The virtual machine provides a crisp, well-defined junction between
the front-end of SQLite (the part that parses SQL statements and generates
virtual machine code) and the back-end (the part that executes the virtual
machine code and computes a result.) The virtual machine allows the developers
to see clearly and in an easily readable form what SQLite is trying to do with each
statement it compiles, which is a tremendous help in debugging. Depending on
how it is compiled, SQLite also has the capability of tracing the execution of the
virtual machine - printing each virtual machine instruction and its result as it
executes.
Public domain
The source code for SQLite is in the public domain. No claim of copyright is made
on any part of the core source code. (The documentation and test code is a
different matter - some sections of documentation and test logic are governed by
open-source licenses.) All contributors to the SQLite core software have signed
affidavits specifically disavowing any copyright interest in the code. This means
that anybody is able to legally do anything they want with the SQLite source
code.
There are other SQL database engines with liberal licenses that allow the code to
be broadly and freely used. But those other engines are still governed by
copyright law. SQLite is different in that copyright law simply does not apply.
The source code files for other SQL database engines typically begin with a
comment describing your license rights to view and copy that file. The SQLite
source code contains no license since it is not governed by copyright. Instead of a
license, the SQLite source code offers a blessing:
Most SQL database engines (every SQL database engine other than SQLite, as far
as we know) uses static, rigid typing. With static typing, the datatype of a value
is determined by its container - the particular column in which the value is stored.
SQLite uses a more general dynamic type system. In SQLite, the datatype of a
value is associated with the value itself, not with its container. The dynamic type
system of SQLite is backwards compatible with the more common static type
systems of other database engines in the sense that SQL statement that work on
statically typed databases should work the same way in SQLite. However, the
dynamic typing in SQLite allows it to do things which are not possible in
traditional rigidly typed databases.
1.0 Storage Classes and Datatypes
Each value stored in an SQLite database (or manipulated by the database engine)
has one of the following storage classes:
Note that a storage class is slightly more general than a datatype. The INTEGER
storage class, for example, includes 6 different integer datatypes of different
lengths. This makes a difference on disk. But as soon as INTEGER values are read
off of disk and into memory for processing, they are converted to the most
general datatype (8-byte signed integer). And so for the most part, "storage
class" is indistinguishable from "datatype" and the two terms can be used
interchangeably.
All values in SQL statements, whether they are literals embedded in SQL
statement text or parameters bound to precompiled SQL statements have an
implicit storage class. Under circumstances described below, the database engine
may convert values between numeric storage classes (INTEGER and REAL) and
TEXT during query execution.
1.1 Boolean Datatype
SQLite does not have a separate Boolean storage class. Instead, Boolean values
are stored as integers 0 (false) and 1 (true).
1.2 Date and Time Datatype
SQLite does not have a storage class set aside for storing dates and/or times.
Instead, the built-in Date And Time Functions of SQLite are capable of storing
dates and times as TEXT, REAL, or INTEGER values:
Applications can chose to store dates and times in any of these formats and freely
convert between formats using the built-in date and time functions.
2.0 Type Affinity
• TEXT
• NUMERIC
• INTEGER
• REAL
• NONE
A column with TEXT affinity stores all data using storage classes NULL, TEXT or
BLOB. If numerical data is inserted into a column with TEXT affinity it is converted
into text form before being stored.
A column with NUMERIC affinity may contain values using all five storage classes.
When text data is inserted into a NUMERIC column, the storage class of the text
is converted to INTEGER or REAL (in order of preference) if such conversion is
lossless and reversible. For conversions between TEXT and REAL storage classes,
SQLite considers the conversion to be lossless and reversible if the first 15
significant decimal digits of the number are preserved. If the lossless conversion
of TEXT to INTEGER or REAL is not possible then the value is stored using the
TEXT storage class. No attempt is made to convert NULL or BLOB values.
A string might look like a floating-point literal with a decimal point and/or
exponent notation but as long as the value can be expressed as an integer, the
NUMERIC affinity will convert it into an integer. Hence, the string '3.0e+5' is
stored in a column with NUMERIC affinity as the integer 300000, not as the
floating point value 300000.0.
A column that uses INTEGER affinity behaves the same as a column with
NUMERIC affinity. The difference between INTEGER and NUMERIC affinity is only
evident in a CAST expression.
A column with REAL affinity behaves like a column with NUMERIC affinity except
that it forces integer values into floating point representation. (As an internal
optimization, small floating point values with no fractional component and stored
in columns with REAL affinity are written to disk as integers in order to take up
less space and are automatically converted back into floating point as the value is
read out. This optimization is completely invisible at the SQL level and can only
be detected by examining the raw bits of the database file.)
A column with affinity NONE does not prefer one storage class over another and
no attempt is made to coerce data from one storage class into another.
2.1 Determination Of Column Affinity
1. If the declared type contains the string "INT" then it is assigned INTEGER
affinity.
2. If the declared type of the column contains any of the strings "CHAR",
"CLOB", or "TEXT" then that column has TEXT affinity. Notice that the type
VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity.
3. If the declared type for a column contains the string "BLOB" or if no type
is specified then the column has affinity NONE.
4. If the declared type for a column contains any of the strings "REAL",
"FLOA", or "DOUB" then the column has REAL affinity.
5. Otherwise, the affinity is NUMERIC.
Note that the order of the rules for determining column affinity is important. A
column whose declared type is "CHARINT" will match both rules 1 and 2 but the
first rule takes precedence and so the column affinity will be INTEGER.
2.2 Affinity Name Examples
The following table shows how many common datatype names from more
traditional SQL implementations are converted into affinities by the five rules of
the previous section. This table shows only a small subset of the datatype names
that SQLite will accept. Note that numeric arguments in parentheses that
following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite
does not impose any length restrictions (other than the large global
SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values.
INT INTEGER 1
INTEGER
TINYINT
SMALLINT
MEDIUMINT
BIGINT
UNSIGNED BIG INT
INT2
INT8
CHARACTER(20)
VARCHAR(255)
VARYING CHARACTER(255)
NCHAR(55)
TEXT 2
NATIVE CHARACTER(70)
NVARCHAR(100)
TEXT
CLOB
BLOB
NONE 3
no datatype specified
REAL
DOUBLE
REAL 4
DOUBLE PRECISION
FLOAT
NUMERIC
DECIMAL(10,5)
BOOLEAN NUMERIC 5
DATE
DATETIME
Note that a declared type of "FLOATING POINT" would give INTEGER affinity, not
REAL affinity, due to the "INT" at the end of "POINT". And the declared type of
"STRING" has an affinity of NUMERIC, not TEXT.
2.3 Column Affinity Behavior Example
The following SQL demonstrates how SQLite uses column affinity to do type
conversions when values are inserted into a table.
SQLite version 3 has the usual set of SQL comparison operators including "=",
"==", "<", "<=", ">", ">=", "!=", "<>", "IN", "NOT IN", "BETWEEN", "IS", and
"IS NOT", .
3.1 Sort Order
• A value with storage class NULL is considered less than any other value
(including another value with storage class NULL).
• An INTEGER or REAL value is less than any TEXT or BLOB value. When an
INTEGER or REAL is compared to another INTEGER or REAL, a numerical
comparison is performed.
• A TEXT value is less than a BLOB value. When two TEXT values are
compared an appropriate collating sequence is used to determine the
result.
• When two BLOB values are compared, the result is determined using
memcmp().
SQLite may attempt to convert values between the storage classes INTEGER,
REAL, and/or TEXT before performing a comparison. Whether or not any
conversions are attempted before the comparison takes place depends on the
affinity of the operands. Operand affinity is determined by the following rules:
• If one operand has INTEGER, REAL or NUMERIC affinity and the other
operand as TEXT or NONE affinity then NUMERIC affinity is applied to
other operand.
• If one operand has TEXT affinity and the other has NONE affinity, then
TEXT affinity is applied to the other operand.
• Otherwise, no affinity is applied and both operands are compared as is.
The expression "a BETWEEN b AND c" is treated as two separate binary
comparisons "a >= b AND a <= c", even if that means different affinities are
applied to 'a' in each of the comparisons. Datatype conversions in comparisons of
the form "x IN (SELECT y ...)" are handled is if the comparison were really "x=y".
The expression "a IN (x, y, z, ...)" is equivalent to "a = +x OR a = +y OR a = +z
OR ...". In other words, the values to the right of the IN operator (the "x", "y",
and "z" values in this example) are considered to have no affinity, even if they
happen to be column values or CAST expressions.
3.4 Comparison Example
All of the result in the example are the same if the comparisons are commuted -
if expressions of the form "a<40" are rewritten as "40>a".
4.0 Operators
All mathematical operators (+, -, *, /, %, <<, >>, &, and |) cast both operands
to the NUMERIC storage class prior to being carried out. The cast is carried
through even if it is lossy and irreversible. A NULL operand on a mathematical
operator yields a NULL result. An operand on a mathematical operator that does
not look in any way numeric and is not NULL is converted to 0 or 0.0.
5.0 Sorting, Grouping and Compound SELECTs
When query results are sorted by an ORDER BY clause, values with storage class
NULL come first, followed by INTEGER and REAL values interspersed in numeric
order, followed by TEXT values in collating sequence order, and finally BLOB
values in memcmp() order. No storage class conversions occur before the sort.
When grouping values with the GROUP BY clause values with different storage
classes are considered distinct, except for INTEGER and REAL values which are
considered equal if they are numerically equal. No affinities are applied to any
values as the result of a GROUP by clause.
The rules for determining which collating function to use for a binary comparison
operator (=, <, >, <=, >=, !=, IS, and IS NOT) are as follows and in the order
shown:
1. If either operand has an explicit collating function assignment using the
postfix COLLATE operator, then the explicit collating function is used for
comparison, with precedence to the collating function of the left operand.
2. If either operand is a column, then the collating function of that column is
used with precedence to the left operand. For the purposes of the previous
sentence, a column name preceded by one or more unary "+" operators is
still considered a column name.
3. Otherwise, the BINARY collating function is used for comparison.
The expression "x BETWEEN y and z" is logically equivalent to two comparisons "x
>= y AND x <= z" and works with respect to collating functions as if it were two
separate comparisons. The expression "x IN (SELECT y ...)" is handled in the
same way as the expression "x = y" for the purposes of determining the collating
sequence. The collating sequence used for expressions of the form "x IN (y,
z, ...)" is the collating sequence of x.
The examples below identify the collating sequences that would be used to
determine the results of text comparisons that may be performed by various SQL
statements. Note that a text comparison may not be required, and no collating
sequence used, in the case of numeric, blob or NULL values.
Rather than try to list all the features of SQL92 that SQLite does support, it is
much easier to list those that it does not. Unsupported features of SQL92 are
shown below.
The order of this list gives some hint as to when a feature might be added to
SQLite. Those features near the top of the list are likely to be added in the near
future. There are no immediate plans to add features near the bottom of the list.
RIGHT and LEFT OUTER JOIN is implemented, but not RIGHT OUTER
FULL OUTER JOIN or FULL OUTER JOIN.
JOIN
Complete Only the RENAME TABLE and ADD COLUMN variants of the
ALTER TABLE ALTER TABLE command are supported. Other kinds of ALTER
support TABLE operations such as DROP COLUMN, ALTER COLUMN,
ADD CONSTRAINT, and so forth are omitted.
Complete FOR EACH ROW triggers are supported but not FOR EACH
trigger STATEMENT triggers.
support
GRANT and Since SQLite reads and writes an ordinary disk file, the only
REVOKE access permissions that can be applied are the normal file
access permissions of the underlying operating system. The
GRANT and REVOKE commands commonly found on
client/server RDBMSes are not implemented because they
would be meaningless for an embedded database engine.
If you find other SQL92 features that SQLite does not support, please add them
to the Wiki page at http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSql
SQLite Limitations
SQLite is different from most other modern SQL databases in that its primary
design goal is to be simple. SQLite follows this goal, even if it leads to occasional
inefficient implementations of some features. The following is a list of
shortcomings of SQLite:
SQL-92 feature
Low concurrency
SQLite supports only flat transactions; it does not have nesting and
savepoint capabilities. (Nesting means the capability of having
subtransactions in a transaction. Savepoints allow a transaction to revert
back to previously established states.) It is not capable of ensuring a high
degree of transaction concurrency. It permits many concurrent read-
transactions, but only one exclusive write-transaction on a single database
file. This limitation means that if any transaction is reading from any part
of a database file, all other transactions are prevented from writing any
part of the file. Similarly, if any one transaction is writing to any part of a
database file, all other transactions are prevented from reading or writing
any part of the file.
Application restriction
NFS problems
SQLite uses native file locking primitives to control transaction
concurrency. This may cause some problems if database files reside on
network partitions. Many NFS implementations are known to contain bugs
(on Unix and Windows) in their file locking logic. If file locking does not
work the way it is expected, it might be possible for two or more
applications to modify the same part of the same database at the same
time, resulting in a database corruption. Because this problem arises due
to bugs in the underlying filesystem implementation, there is nothing
SQLite can do to prevent it.
Another thing is that because of the latency associated with most network
filesystems, performance may not be good. In such environments, in
cases where the database files must be accessed across the network, a
DBMS that implements a client-server model might be more effective than
SQLite.
Database size
A table or index is limited by at most 264 – 1 entries. (Of course, you
cannot have this many entries because of the 241 bytes database size
limit.) A single entry can hold up to 230 bytes of data in SQLite's current
implementation. (The underlying file format supports row sizes up to
about 262 bytes of data.) Upon opening a database file, SQLite reads and
preprocesses all entries from the master catalog table and creates many
in-memory catalog objects. So, for best performance, it is better to keep
down the number of tables, indexes, views, and triggers. Likewise, though
there is no limit on the number of columns in a table, more than a few
hundred seems extreme. Only the first 31 columns of a table are
candidates for certain optimizations. You can put as many columns in an
index as you like, but indexes with more than 30 columns will not be used
to optimize queries.
Stored procedure
Many DBMSs have capability to create and store what are called stored
procedures. A stored procedure is a group of SQL statements that form a
logical unit of work and perform a particular task. SQL queries can use
these procedures. SQLite does not have this capability.
PostgreSQL
PostgreSQL
PostgreSQL Global
Developer(s)
Development Group
9.0.1 /
8.4.5 /
8.3.12 /
8.2.18 /
Stable release
8.1.22 /
8.0.26 /
7.4.30 /
October 4, 2010; 57 days ago
9.1alpha1 / September 7,
Preview release
2010; 2 months ago
Written in C
Operating system Cross-platform
Type ORDBMS
License PostgreSQL licence[1][2][3]
Website http://www.postgresql.org/
[edit] History
Starting in 1986, the team published a number of papers describing the basis of
the system, and by 1988 had a prototype version. The team released version 1 to
a small number of users in June 1989, then version 2 with a re-written rules
system in June 1990. Version 3, released in 1991, again re-wrote the rules
system, and added support for multiple storage managers and an improved query
engine. By 1993 the great number of users began to overwhelm the project with
requests for support and features. After releasing version 4 — primarily a
cleanup — the project ended.
But open-source developers could obtain copies and develop the system further,
because Berkeley had released Postgres under a MIT-style license. In 1994,
Berkeley graduate students Andrew Yu and Jolly Chen replaced the Ingres-based
QUEL query language interpreter with one for the SQL query language, creating
Postgres95. The code was released on the web.
In July 1996, Marc Fournier at Hub.Org Networking Services provided the first
non-university development server for the open-source development effort. Along
with Bruce Momjian and Vadim B. Mikheev, work began to stabilize the code
inherited from Berkeley. The first open-source version was released on August 1,
1996.
In 1996, the project was renamed to PostgreSQL to reflect its support for SQL.
The first PostgreSQL release formed version 6.0 in January 1997. Since then, the
software has been maintained by a group of database developers and volunteers
around the world, coordinating via the Internet.
Community supported
[edit] Features
Other non-standard procedural languages that have been developed outside the
core distribution includes (but is not limited to): PL/Lua (Lua), PL/php (PHP),
PL/Ruby (Ruby), PL/sh (any Unix-like shell), PL/scheme (Scheme), PL/Java
(Java), PL/R (R) and even PL/LOLCODE.
[edit] Indexes
PostgreSQL includes built-in support for B+-tree, hash, GiST and GiN indexes. In
addition, user-defined index methods can be created, although this is quite an
involved process. Indexes in PostgreSQL also support the following features:
[edit] Triggers
Triggers are events triggered by the action of SQL DML statements. For example,
an INSERT statement might activate a trigger that checked if the values of the
statement were valid. Most triggers are only activated by either INSERT or
UPDATE statements.
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
[edit] Rules
Rules allow the "query tree" of an incoming query to be rewritten. One common
usage is to implement views, including updatable views. Rules, or more properly,
"Query Re-Write Rules", are attached to a table/class and "Re-Write" the
incoming DML (select, insert, update, and/or delete) into one or more queries
that either replace the original DML statement or execute in addition to it. Query
Re-Write occurs after DML statement parsing, but, before query planning.
In addition, users can create their own data types which can usually be made
fully indexable via PostgreSQL's GiST infrastructure. Examples of these include
the geographic information system (GIS) data types from the PostGIS project for
PostgreSQL.
New types of almost all objects inside the database can be created, including:
Casts
Conversions
Data types
Domains
Functions, including aggregate functions
Indexes
Operators (existing ones can be overloaded)
Procedural languages
[edit] Inheritance
Tables can be set to inherit their characteristics from a "parent" table. Data in
child tables will appear to exist in the parent tables, unless data is selected from
the parent table using the ONLY keyword, i.e. select * from ONLY
PARENT_TABLE. Adding a column in the parent table will cause that column to
appear in the child table.
As of 2010 this feature is not fully supported yet—in particular, table constraints
are not currently inheritable. As of the 8.4 release, all check constraints and not-
null constraints on a parent table are automatically inherited by its children.
Other types of constraints (unique, primary key, and foreign key constraints) are
not inherited.
[edit] Replication
PostgreSQL 9.0 includes built-in binary replication, based on shipping the changes
(write-ahead logs) to slave systems asynchronously. Adding synchronous
replication is on the roadmap for the 9.1 release.
Version 9.0 also introduces the ability to run read-only queries against these
replicated slaves, where earlier versions would only allow that after promoting
them to be a new master. This allows splitting read traffic among multiple nodes
efficiently. Earlier replication software that allowed similar read scaling normally
relied on adding replication triggers to the master, introducing additional load
onto it.
Slony-I
Londiste (part of SkyTools by Skype)
Mammoth Replicator (by Command Prompt. Formerly proprietary, now
open source)[10]
Bucardo (Multi-master replication, developed as part of Backcountry.com)
[11]
There are also proxy (middleware) tools that enable replication, failover or load
management and balancing for PostgreSQL:
PGPool-II
Continuent Sequoia, also available for other database software
[edit] Add-ons
[edit] psql
The primary front-end for PostgreSQL is the psql command-line program, which
can be used to enter SQL queries directly, or execute them from a file. In
addition, psql provides a number of meta-commands and various shell-like
features to facilitate writing scripts and automating a wide variety of tasks; for
example tab completion of object names and SQL syntax.
[edit] pgAdmin
pgAdmin is a free and open source graphical front-end administration tool for
PostgreSQL, which is supported on most popular computer platforms. The
program is available in more than a dozen languages. The first prototype, named
pgManager, was written for PostgreSQL 6.3.2 from 1998, and rewritten and
released as pgAdmin under the GPL License in later months. The second
incarnation (named pgAdmin II) was a complete rewrite, first released on 16
January 2002. The current version is pgAdmin III, which was originally released
under the Artistic License and is now released under the same license as
PostgreSQL. Unlike prior versions that were written in Visual Basic, pgAdmin III is
written in C++, using the wxWidgets framework allowing it to run on most
common operating systems.
[edit] phpPgAdmin
[edit] Proprietary
A number of companies offer proprietary tools for PostgreSQL. They often consist
of a universal core that is adapted for various specific database products. These
tools mostly share the administration features with the open source tools but
offer improvements in data modeling, importing, exporting or reporting.
Yahoo! for web user behavioral analysis, storing two petabytes and
claimed to be the largest data warehouse using a heavily modified
version of PostgreSQL with an entirely different column-based storage
engine and different query processing layer. While for performance,
storage, and query purposes the database bears little resemblance to
PostgreSQL, the front-end maintains compatibility so that Yahoo can use
many off-the-shelf tools already written to interact with PostgreSQL.[17][18]
MySpace, a popular social networking website, is using Aster
nCluster Database for data warehousing, which is built on unmodified
PostgreSQL.[19][20]
OpenStreetMap, a collaborative project to create a free editable
map of the world.[21]
Afilias, domain registries for .org, .info and others.[22]
Sony Online multiplayer online games.[23]
BASF, shopping platform for their agribusiness portal.[24]
hi5.com social networking portal.[25]
reddit.com social news website.[26]
Skype VoIP application, central business databases.[27]
Sun xVM, Sun's virtualization and datacenter automation suite.[28]
Evergreen, an open source integrated library system providing an
Online Public Access Catalog and cataloging, management, and other
functions for hundreds of libraries in the United States, Canada, and
elsewhere.
MusicBrainz, open online music encyclopedia.
International Space Station for collecting telemetry data in orbit
and replicating to the ground.[29]
MyYearbook social networking site[30]
[edit] Awards
In 2000, former Red Hat investors created the company Great Bridge to
make a proprietary product based on PostgreSQL and compete against
proprietary database vendors. Great Bridge sponsored several PostgreSQL
developers and donated many resources back to the community,[32] but by
late 2001 closed due to tough competition from companies like Red Hat and
to poor market conditions.[33]