info > CREATE_LANGUAGE

📖 NAME

CREATE_LANGUAGE - define a new procedural language

🚀 Quick Reference

Use CaseCommandDescription
Create a new procedural languageCREATE LANGUAGE plsample HANDLER plsample_call_handler;Registers a new language with a handler function
Create or replace an existing languageCREATE OR REPLACE LANGUAGE plsample HANDLER plsample_call_handler;Updates parameters of an existing language
Install a language as an extensionCREATE EXTENSION plsample;Convenient way to set up a language packaged as an extension
Drop a languageDROP LANGUAGE plsample;Removes a procedural language
List installed languages\dL (psql command)Lists all languages in the database

📋 SYNOPSIS

CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name
    HANDLER call_handler [ INLINE inline_handler ] [ VALIDATOR valfunction ]
CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name

📝 DESCRIPTION

CREATE LANGUAGE registers a new procedural language with a PostgreSQL database. Subsequently, functions and procedures can be defined in this new language.

CREATE LANGUAGE effectively associates the language name with handler function(s) that are responsible for executing functions written in the language. Refer to Chapter 56 for more information about language handlers.

CREATE OR REPLACE LANGUAGE will either create a new language, or replace an existing definition. If the language already exists, its parameters are updated according to the command, but the language's ownership and permissions settings do not change, and any existing functions written in the language are assumed to still be valid.

One must have the PostgreSQL superuser privilege to register a new language or change an existing language's parameters. However, once the language is created it is valid to assign ownership of it to a non-superuser, who may then drop it, change its permissions, rename it, or assign it to a new owner. (Do not, however, assign ownership of the underlying C functions to a non-superuser; that would create a privilege escalation path for that user.)

The form of CREATE LANGUAGE that does not supply any handler function is obsolete. For backwards compatibility with old dump files, it is interpreted as CREATE EXTENSION. That will work if the language has been packaged into an extension of the same name, which is the conventional way to set up procedural languages.

⚙️ PARAMETERS

📝 NOTES

Use DROP LANGUAGE to drop procedural languages.

The system catalog pg_language (see Section 52.29) records information about the currently installed languages. Also, the psql command \dL lists the installed languages.

To create functions in a procedural language, a user must have the USAGE privilege for the language. By default, USAGE is granted to PUBLIC (i.e., everyone) for trusted languages. This can be revoked if desired.

Procedural languages are local to individual databases. However, a language can be installed into the template1 database, which will cause it to be available automatically in all subsequently-created databases.

💡 EXAMPLES

A minimal sequence for creating a new procedural language is:

CREATE FUNCTION plsample_call_handler() RETURNS language_handler
    AS '$libdir/plsample'
    LANGUAGE C;
CREATE LANGUAGE plsample
    HANDLER plsample_call_handler;

Typically that would be written in an extension's creation script, and users would do this to install the extension:

CREATE EXTENSION plsample;

🔗 COMPATIBILITY

CREATE LANGUAGE is a PostgreSQL extension.

📚 SEE ALSO

ALTER LANGUAGE (ALTER_LANGUAGE(7)), CREATE FUNCTION (CREATE_FUNCTION(7)), DROP LANGUAGE (DROP_LANGUAGE(7)), GRANT(7), REVOKE(7)


PostgreSQL 14.23 2026 CREATE LANGUAGE(7)

CREATE_LANGUAGE
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION ⚙️ PARAMETERS 📝 NOTES 💡 EXAMPLES 🔗 COMPATIBILITY 📚 SEE ALSO

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-16 08:47 @2600:1f28:365:80b0:7cb9:fb:26c1:e368
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!