1CREATE EXTENSION(7)      PostgreSQL 10.7 Documentation     CREATE EXTENSION(7)
2
3
4

NAME

6       CREATE_EXTENSION - install an extension
7

SYNOPSIS

9       CREATE EXTENSION [ IF NOT EXISTS ] extension_name
10           [ WITH ] [ SCHEMA schema_name ]
11                    [ VERSION version ]
12                    [ FROM old_version ]
13                    [ CASCADE ]
14

DESCRIPTION

16       CREATE EXTENSION loads a new extension into the current database. There
17       must not be an extension of the same name already loaded.
18
19       Loading an extension essentially amounts to running the extension's
20       script file. The script will typically create new SQL objects such as
21       functions, data types, operators and index support methods.  CREATE
22       EXTENSION additionally records the identities of all the created
23       objects, so that they can be dropped again if DROP EXTENSION is issued.
24
25       Loading an extension requires the same privileges that would be
26       required to create its component objects. For most extensions this
27       means superuser or database owner privileges are needed. The user who
28       runs CREATE EXTENSION becomes the owner of the extension for purposes
29       of later privilege checks, as well as the owner of any objects created
30       by the extension's script.
31

PARAMETERS

33       IF NOT EXISTS
34           Do not throw an error if an extension with the same name already
35           exists. A notice is issued in this case. Note that there is no
36           guarantee that the existing extension is anything like the one that
37           would have been created from the currently-available script file.
38
39       extension_name
40           The name of the extension to be installed.  PostgreSQL will create
41           the extension using details from the file
42           SHAREDIR/extension/extension_name.control.
43
44       schema_name
45           The name of the schema in which to install the extension's objects,
46           given that the extension allows its contents to be relocated. The
47           named schema must already exist. If not specified, and the
48           extension's control file does not specify a schema either, the
49           current default object creation schema is used.
50
51           If the extension specifies a schema parameter in its control file,
52           then that schema cannot be overridden with a SCHEMA clause.
53           Normally, an error will be raised if a SCHEMA clause is given and
54           it conflicts with the extension's schema parameter. However, if the
55           CASCADE clause is also given, then schema_name is ignored when it
56           conflicts. The given schema_name will be used for installation of
57           any needed extensions that do not specify schema in their control
58           files.
59
60           Remember that the extension itself is not considered to be within
61           any schema: extensions have unqualified names that must be unique
62           database-wide. But objects belonging to the extension can be within
63           schemas.
64
65       version
66           The version of the extension to install. This can be written as
67           either an identifier or a string literal. The default version is
68           whatever is specified in the extension's control file.
69
70       old_version
71           FROM old_version must be specified when, and only when, you are
72           attempting to install an extension that replaces an “old style”
73           module that is just a collection of objects not packaged into an
74           extension. This option causes CREATE EXTENSION to run an
75           alternative installation script that absorbs the existing objects
76           into the extension, instead of creating new objects. Be careful
77           that SCHEMA specifies the schema containing these pre-existing
78           objects.
79
80           The value to use for old_version is determined by the extension's
81           author, and might vary if there is more than one version of the
82           old-style module that can be upgraded into an extension. For the
83           standard additional modules supplied with pre-9.1 PostgreSQL, use
84           unpackaged for old_version when updating a module to extension
85           style.
86
87       CASCADE
88           Automatically install any extensions that this extension depends on
89           that are not already installed. Their dependencies are likewise
90           automatically installed, recursively. The SCHEMA clause, if given,
91           applies to all extensions that get installed this way. Other
92           options of the statement are not applied to automatically-installed
93           extensions; in particular, their default versions are always
94           selected.
95

NOTES

97       Before you can use CREATE EXTENSION to load an extension into a
98       database, the extension's supporting files must be installed.
99       Information about installing the extensions supplied with PostgreSQL
100       can be found in Additional Supplied Modules.
101
102       The extensions currently available for loading can be identified from
103       the pg_available_extensions or pg_available_extension_versions system
104       views.
105
106       For information about writing new extensions, see Section 37.15.
107

EXAMPLES

109       Install the hstore extension into the current database:
110
111           CREATE EXTENSION hstore;
112
113       Update a pre-9.1 installation of hstore into extension style:
114
115           CREATE EXTENSION hstore SCHEMA public FROM unpackaged;
116
117       Be careful to specify the schema in which you installed the existing
118       hstore objects.
119

COMPATIBILITY

121       CREATE EXTENSION is a PostgreSQL extension.
122

SEE ALSO

124       ALTER EXTENSION (ALTER_EXTENSION(7)), DROP EXTENSION
125       (DROP_EXTENSION(7))
126
127
128
129PostgreSQL 10.7                      2019                  CREATE EXTENSION(7)
Impressum