Registers an extension in a Greenplum database.
CREATE EXTENSION [ IF NOT EXISTS ] <extension_name> [ WITH ] [ SCHEMA <schema_name> ] [ VERSION <version> ] [ FROM <old_version> ] [ CASCADE ]
CREATE EXTENSION loads a new extension into the current database. There must not be an extension of the same name already loaded.
Loading an extension essentially amounts to running the extension script file. The script typically creates new SQL objects such as functions, data types, operators and index support methods. The
CREATE EXTENSION command also records the identities of all the created objects, so that they can be dropped again if
DROP EXTENSION is issued.
Loading an extension requires the same privileges that would be required to create the component extension objects. For most extensions this means superuser or database owner privileges are required. The user who runs
CREATE EXTENSION becomes the owner of the extension for purposes of later privilege checks, as well as the owner of any objects created by the extension script.
SHAREDIR is the installation shared-data directory, for example
/usr/local/greenplum-db/share/postgresql. The command
pg_config --sharedir displays the directory.
If the extension specifies a schema parameter in its control file, then that schema cannot be overridden with a
SCHEMA clause. Normally, an error is raised if a
SCHEMA clause is given and it conflicts with the extension schema parameter. However, if the
CASCADE clause is also given, then schema_name is ignored when it conflicts. The given schema_name is used for the installation of any needed extensions that do not a specify schema in their control files.
The extension itself is not within any schema. Extensions have unqualified names that must be unique within the database. But objects belonging to the extension can be within a schema.
FROM old\_versiononly if you are attempting to install an extension that replaces an old-style module that is a collection of objects that is not packaged into an extension. If specified,
CREATE EXTENSIONruns an alternative installation script that absorbs the existing objects into the extension, instead of creating new objects. Ensure that
SCHEMAclause specifies the schema containing these pre-existing objects.
The value to use for old_version is determined by the extension author, and might vary if there is more than one version of the old-style module that can be upgraded into an extension. For the standard additional modules supplied with pre-9.1 PostgreSQL, specify
unpackaged for the old_version when updating a module to extension style.
Before you use
CREATE EXTENSION to load an extension into a database, the supporting extension files must be installed including an extension control file and at least one least one SQL script file. The support files must be installed in the same location on all Greenplum Database hosts. For information about creating new extensions, see PostgreSQL information about Packaging Related Objects into an Extension.
CREATE EXTENSION is a Greenplum Database extension.
Parent topic: SQL Commands