Child pages
  • PostgreSQL Primer

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This tutorial is by no means a replacement for the excellent PostgreSQL documentation that can be found here.

The goal of this tutorial primer is to provide a starting point for the most common actions for working with PostgreSQL, with pointers to more in-depth documentation where applicable.   

Table of Contents

Servoy & PostgreSQL

As of Servoy 5.2 Servoy comes bundled with PostgreSQL. This means that when the option to install the databases in the All-In-One installer is checked, the installer will install the PostgreSQL database engine. 

The PostgreSQL database engine is installed in the ../application_server/postgres_db/ directory. The actual databases and configuration files are stored in the ../application_server/database/ directory.

Note that while Servoy comes bundled with PostgreSQL, Servoy is 100% database agnostic. The PostgreSQL database can therefor be replaced by any type of database. 

Bundled PostgreSQL version

Which version of PostgreSQL is shipped with a specific version of Servoy can be found in the Servoy documentation for the specific Servoy version. For the latest version, see the Servoy Stack Info here.

Installing PostgreSQL

As of Servoy 5.2 Servoy comes bundles with PostgreSQL. When selecting the Database option int eh All-In-One installer, PostgreSQL is automatically installed and Servoy is setup to connect to it. 

....

While PostgreSQL comes bundles with Servoy, the PostgreSQL installation provided through the Servoy All-In-One installer is a basic installation. Thus many people prefer  

Unix variants

TODO

Windows

As of Servoy 5.2 PostgreSQL is bundled with Servoy by default. The bundles PostgreSQL is however a very basic install. For production purposes it is also possible to use a dedicated PostgreSQL installer from EnterpriseDB.

Upgrading PostgreSQL

TODO

Starting and stopping PostgreSQL manually

Through the pg_ctl tool that comes with PostgreSQL, it is easy to start and stop a PostgreSQL database. In a default installation the  pg_ctl tool is located in ../application_server/postgres_db/bin/ directory.

Starting PostgreSQL

Code Block

postgres_db\bin\pg_ctl start -D database -l postgres_db\postgres_log.txt

Stopping PostgreSQL 

Code Block

postgres_db\bin\pg_ctl stop -D database

The commands above assume execution from the ../application_server/ directory. When executing from a different location, make sure to update the paths to the database (-D database) and the logfile (-l postgres_db\postgres_log.txt).

Running PostgreSQL as a Service

...

Windows

...

The pg_ctl utility that comes with PostgreSQL has a built-in command to register the PostgreSQL database as a Windows Service

Registering the Windows Service

Code Block

postgres_db\bin\pg_ctl register -N PostgreSQL -D database

Unregistering the Windows Service

Code Block

postgres_db\bin\pg_ctl unregister -N PostgreSQL

The commands above assume execution from the ../application_server/ directory. When executing from a different location, make sure to update the paths to the database (-D database).

The -N option specifies the name for the Windows Service. Make sure the name is unique. 

...

OSX

...

TODO

...

*nix

...

TODO

Performing backups

Manual backups

TODO

Scheduled backups

TODO

PostgreSQL Database Admin tool

For PostgreSQL there are multiple admin tools available, from commercial to open source. The most used admin tool for PostgreSQL is the open source, cross-platform PgAdmin. It

PgAdmin can be downloaded here and the excellent documentation is available here.

The EnterpriseDB installer for PostgreSQL has the PgAdmin tool bundled.  

PostgreSQL SQL Tips 'n' Tricks

...