Installing PL/pgSQL

PostgreSQL can support a variety of procedural languages. Before you can use a procedural language, you have to install it into the database. Fortunately, this is a simple procedure.

The createlang shell script installs PL/pgSQL into a database. If you install PL/pgSQL in the template1 database, it will automatically be installed in all databases created from that template. The format for createlang is

createlang plpgsql database-name

To install PL/pgSQL in the movies database, execute the following command:

$ createlang plpgsql movies

Notice that this is a command-line utility, not a psql command.

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.