PostgreSQL

Implementation of programming language SQL

PostgreSQL is an object-relational database management system developed by PostgreSQL Global Development Group. It uses SQL as query language. It is distributed under MIT-style license and is available for multiple platforms.

Features:

  • implements most features of SQL-2008 standard.
  • ensures efficient maintenance of ACID principles (atomicity, consistency, isolation, durability).
  • fully transactional, including DDL statements.
  • if one needs procedural language, one can use either PL/plSQL (a built-in language similar to Oracle PL/SQL) or one of the other languages provided by PostgreSQL. The standard installation includes Tcl, Python and Perl, and there are plenty of others available as extensions.

PostgreSQL logo
PostgreSQL logo

Examples:

Hello, World!:

Example for versions Microsoft SQL Server 2005, Microsoft SQL Server 2008 R2, Microsoft SQL Server 2012, MySQL 3.23.57, PostgreSQL 9.1
select 'Hello, World!';

Factorial:

Example for versions PostgreSQL 9.1

The task of factorials calculation is solved using standard methods only: a built-in factorial function ! (postfix form; there is also a prefix form !!) and a set function generate_series which generates a set of rows containing values between the first and the second parameters.

select n || '! = ' || (n!)
  from generate_series(0,16) as seq(n);

Fibonacci numbers:

Example for versions PostgreSQL 9.1
WITH RECURSIVE t(a,b) AS (
        VALUES(1,1)
    UNION ALL
        SELECT b, a + b FROM t
        WHERE b < 1000
   )
SELECT array_to_string(array(SELECT a FROM t), ', ') || ', ...';