{
    "content": [
        {
            "type": "text",
            "text": "# CREATE_EXTENSION (man)\n\n## NAME\n\nCREATEEXTENSION - install an extension\n\n## SYNOPSIS\n\nCREATE EXTENSION [ IF NOT EXISTS ] extensionname\n[ WITH ] [ SCHEMA schemaname ]\n[ VERSION version ]\n[ CASCADE ]\n\n## DESCRIPTION\n\nCREATE EXTENSION loads a new extension into the current database. There must not be an\nextension of the same name already loaded.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PARAMETERS**\n- **NOTES**\n- **EXAMPLES**\n- **COMPATIBILITY**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "CREATE_EXTENSION",
        "section": "",
        "mode": "man",
        "summary": "CREATEEXTENSION - install an extension",
        "synopsis": "CREATE EXTENSION [ IF NOT EXISTS ] extensionname\n[ WITH ] [ SCHEMA schemaname ]\n[ VERSION version ]\n[ CASCADE ]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Install the hstore extension into the current database, placing its objects in schema addons:",
            "CREATE EXTENSION hstore SCHEMA addons;",
            "Another way to accomplish the same thing:",
            "SET searchpath = addons;",
            "CREATE EXTENSION hstore;"
        ],
        "see_also": [
            {
                "name": "ALTEREXTENSION",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/ALTEREXTENSION/7/json"
            },
            {
                "name": "DROPEXTENSION",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/DROPEXTENSION/7/json"
            },
            {
                "name": "EXTENSION",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/EXTENSION/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "PARAMETERS",
                "lines": 39,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "COMPATIBILITY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "CREATEEXTENSION - install an extension\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "CREATE EXTENSION [ IF NOT EXISTS ] extensionname\n[ WITH ] [ SCHEMA schemaname ]\n[ VERSION version ]\n[ CASCADE ]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "CREATE EXTENSION loads a new extension into the current database. There must not be an\nextension of the same name already loaded.\n\nLoading an extension essentially amounts to running the extension's script file. The script\nwill typically create new SQL objects such as functions, data types, operators and index\nsupport methods.  CREATE EXTENSION additionally records the identities of all the created\nobjects, so that they can be dropped again if DROP EXTENSION is issued.\n\nThe user who runs CREATE EXTENSION becomes the owner of the extension for purposes of later\nprivilege checks, and normally also becomes the owner of any objects created by the\nextension's script.\n\nLoading an extension ordinarily requires the same privileges that would be required to create\nits component objects. For many extensions this means superuser privileges are needed.\nHowever, if the extension is marked trusted in its control file, then it can be installed by\nany user who has CREATE privilege on the current database. In this case the extension object\nitself will be owned by the calling user, but the contained objects will be owned by the\nbootstrap superuser (unless the extension's script explicitly assigns them to the calling\nuser). This configuration gives the calling user the right to drop the extension, but not to\nmodify individual objects within it.\n",
                "subsections": []
            },
            "PARAMETERS": {
                "content": "IF NOT EXISTS\nDo not throw an error if an extension with the same name already exists. A notice is\nissued in this case. Note that there is no guarantee that the existing extension is\nanything like the one that would have been created from the currently-available script\nfile.\n\nextensionname\nThe name of the extension to be installed.  PostgreSQL will create the extension using\ndetails from the file SHAREDIR/extension/extensionname.control.\n\nschemaname\nThe name of the schema in which to install the extension's objects, given that the\nextension allows its contents to be relocated. The named schema must already exist. If\nnot specified, and the extension's control file does not specify a schema either, the\ncurrent default object creation schema is used.\n\nIf the extension specifies a schema parameter in its control file, then that schema\ncannot be overridden with a SCHEMA clause. Normally, an error will be raised if a SCHEMA\nclause is given and it conflicts with the extension's schema parameter. However, if the\nCASCADE clause is also given, then schemaname is ignored when it conflicts. The given\nschemaname will be used for installation of any needed extensions that do not specify\nschema in their control files.\n\nRemember that the extension itself is not considered to be within any schema: extensions\nhave unqualified names that must be unique database-wide. But objects belonging to the\nextension can be within schemas.\n\nversion\nThe version of the extension to install. This can be written as either an identifier or a\nstring literal. The default version is whatever is specified in the extension's control\nfile.\n\nCASCADE\nAutomatically install any extensions that this extension depends on that are not already\ninstalled. Their dependencies are likewise automatically installed, recursively. The\nSCHEMA clause, if given, applies to all extensions that get installed this way. Other\noptions of the statement are not applied to automatically-installed extensions; in\nparticular, their default versions are always selected.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "Before you can use CREATE EXTENSION to load an extension into a database, the extension's\nsupporting files must be installed. Information about installing the extensions supplied with\nPostgreSQL can be found in Additional Supplied Modules.\n\nThe extensions currently available for loading can be identified from the\npgavailableextensions or pgavailableextensionversions system views.\n\nCaution\nInstalling an extension as superuser requires trusting that the extension's author wrote\nthe extension installation script in a secure fashion. It is not terribly difficult for a\nmalicious user to create trojan-horse objects that will compromise later execution of a\ncarelessly-written extension script, allowing that user to acquire superuser privileges.\nHowever, trojan-horse objects are only hazardous if they are in the searchpath during\nscript execution, meaning that they are in the extension's installation target schema or\nin the schema of some extension it depends on. Therefore, a good rule of thumb when\ndealing with extensions whose scripts have not been carefully vetted is to install them\nonly into schemas for which CREATE privilege has not been and will not be granted to any\nuntrusted users. Likewise for any extensions they depend on.\n\nThe extensions supplied with PostgreSQL are believed to be secure against\ninstallation-time attacks of this sort, except for a few that depend on other extensions.\nAs stated in the documentation for those extensions, they should be installed into secure\nschemas, or installed into the same schemas as the extensions they depend on, or both.\n\nFor information about writing new extensions, see Section 38.17.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "Install the hstore extension into the current database, placing its objects in schema addons:\n\nCREATE EXTENSION hstore SCHEMA addons;\n\nAnother way to accomplish the same thing:\n\nSET searchpath = addons;\nCREATE EXTENSION hstore;\n",
                "subsections": []
            },
            "COMPATIBILITY": {
                "content": "CREATE EXTENSION is a PostgreSQL extension.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "ALTER EXTENSION (ALTEREXTENSION(7)), DROP EXTENSION (DROPEXTENSION(7))\n\n\n\nPostgreSQL 14.23                                2026                             CREATE EXTENSION(7)",
                "subsections": []
            }
        }
    }
}