Core support for "extensions", which are packages of SQL objects.
[pgsql.git] / doc / src / sgml / ref / create_extension.sgml
blob961cab3839e0ee2d9a4292e4f95cf34a03469e27
1 <!--
2 doc/src/sgml/ref/create_extension.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="SQL-CREATEEXTENSION">
7 <refmeta>
8 <refentrytitle>CREATE EXTENSION</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
11 </refmeta>
13 <refnamediv>
14 <refname>CREATE EXTENSION</refname>
15 <refpurpose>install an extension</refpurpose>
16 </refnamediv>
18 <indexterm zone="sql-createextension">
19 <primary>CREATE EXTENSION</primary>
20 </indexterm>
22 <refsynopsisdiv>
23 <synopsis>
24 CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable>
25 [ WITH ] [ SCHEMA [=] <replaceable class="parameter">schema</replaceable> ]
26 </synopsis>
27 </refsynopsisdiv>
29 <refsect1>
30 <title>Description</title>
32 <para>
33 <command>CREATE EXTENSION</command> loads a new extension into the current
34 database. There must not be an extension of the same name already loaded.
35 </para>
37 <para>
38 Loading an extension essentially amounts to running the extension's script
39 file. The script will typically create new <acronym>SQL</> objects such as
40 functions, data types, operators and index support methods.
41 <command>CREATE EXTENSION</command> additionally records the identities
42 of all the created objects, so that they can be dropped again if
43 <command>DROP EXTENSION</command> is issued.
44 </para>
46 <para>
47 For information about writing new extensions, see
48 <xref linkend="extend-extensions">.
49 </para>
51 <para>
52 Only superusers can execute <command>CREATE EXTENSION</command>.
53 </para>
55 </refsect1>
57 <refsect1>
58 <title>Parameters</title>
60 <variablelist>
61 <varlistentry>
62 <term><replaceable class="parameter">extension_name</replaceable></term>
63 <listitem>
64 <para>
65 The name of the extension to be
66 installed. <productname>PostgreSQL</productname> will create the
67 extension using details from the file
68 <literal>SHAREDIR/contrib/</literal><replaceable class="parameter">extension</replaceable><literal>.control</literal>.
69 </para>
70 </listitem>
71 </varlistentry>
73 <varlistentry>
74 <term><replaceable class="parameter">schema</replaceable></term>
75 <listitem>
76 <para>
77 The name of the schema in which to install the extension's
78 objects, given that the extension allows its contents to be
79 relocated. The named schema must already exist.
80 If not specified, and the extension's control file does not specify a
81 schema either, the current default object creation schema is used.
82 </para>
83 </listitem>
84 </varlistentry>
85 </variablelist>
86 </refsect1>
88 <refsect1>
89 <title>Examples</title>
91 <para>
92 Install the <link linkend="hstore">hstore</link> extension into the
93 current database:
94 <programlisting>
95 CREATE EXTENSION hstore;
96 </programlisting>
97 </para>
98 </refsect1>
100 <refsect1>
101 <title>Compatibility</title>
103 <para>
104 <command>CREATE EXTENSION</command> is a <productname>PostgreSQL</>
105 extension.
106 </para>
107 </refsect1>
109 <refsect1>
110 <title>See Also</title>
112 <simplelist type="inline">
113 <member><xref linkend="sql-alterextension"></member>
114 <member><xref linkend="sql-dropextension"></member>
115 </simplelist>
116 </refsect1>
118 </refentry>