{
    "mode": "man",
    "parameter": "CREATE_TABLESPACE",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/CREATE_TABLESPACE/7/json",
    "generated": "2026-06-03T01:36:36Z",
    "synopsis": "CREATE TABLESPACE tablespacename\n[ OWNER { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER } ]\nLOCATION 'directory'\n[ WITH ( tablespaceoption = value [, ... ] ) ]",
    "sections": {
        "NAME": {
            "content": "CREATETABLESPACE - define a new tablespace\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "CREATE TABLESPACE tablespacename\n[ OWNER { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER } ]\nLOCATION 'directory'\n[ WITH ( tablespaceoption = value [, ... ] ) ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CREATE TABLESPACE registers a new cluster-wide tablespace. The tablespace name must be\ndistinct from the name of any existing tablespace in the database cluster.\n\nA tablespace allows superusers to define an alternative location on the file system where the\ndata files containing database objects (such as tables and indexes) can reside.\n\nA user with appropriate privileges can pass tablespacename to CREATE DATABASE, CREATE TABLE,\nCREATE INDEX or ADD CONSTRAINT to have the data files for these objects stored within the\nspecified tablespace.\n\nWarning\nA tablespace cannot be used independently of the cluster in which it is defined; see\nSection 23.6.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "tablespacename\nThe name of a tablespace to be created. The name cannot begin with pg, as such names are\nreserved for system tablespaces.\n\nusername\nThe name of the user who will own the tablespace. If omitted, defaults to the user\nexecuting the command. Only superusers can create tablespaces, but they can assign\nownership of tablespaces to non-superusers.\n\ndirectory\nThe directory that will be used for the tablespace. The directory must exist (CREATE\nTABLESPACE will not create it), should be empty, and must be owned by the PostgreSQL\nsystem user. The directory must be specified by an absolute path name.\n\ntablespaceoption\nA tablespace parameter to be set or reset. Currently, the only available parameters are\nseqpagecost, randompagecost, effectiveioconcurrency and maintenanceioconcurrency.\nSetting these values for a particular tablespace will override the planner's usual\nestimate of the cost of reading pages from tables in that tablespace, and the executor's\nprefetching behavior, as established by the configuration parameters of the same name\n(see seqpagecost, randompagecost, effectiveioconcurrency,\nmaintenanceioconcurrency). This may be useful if one tablespace is located on a disk\nwhich is faster or slower than the remainder of the I/O subsystem.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Tablespaces are only supported on systems that support symbolic links.\n\nCREATE TABLESPACE cannot be executed inside a transaction block.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To create a tablespace dbspace at file system location /data/dbs, first create the directory\nusing operating system facilities and set the correct ownership:\n\nmkdir /data/dbs\nchown postgres:postgres /data/dbs\n\nThen issue the tablespace creation command inside PostgreSQL:\n\nCREATE TABLESPACE dbspace LOCATION '/data/dbs';\n\nTo create a tablespace owned by a different database user, use a command like this:\n\nCREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "CREATE TABLESPACE is a PostgreSQL extension.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CREATE DATABASE (CREATEDATABASE(7)), CREATE TABLE (CREATETABLE(7)), CREATE INDEX\n(CREATEINDEX(7)), DROP TABLESPACE (DROPTABLESPACE(7)), ALTER TABLESPACE\n(ALTERTABLESPACE(7))\n\n\n\nPostgreSQL 14.23                                2026                            CREATE TABLESPACE(7)",
            "subsections": []
        }
    },
    "summary": "CREATETABLESPACE - define a new tablespace",
    "flags": [],
    "examples": [
        "To create a tablespace dbspace at file system location /data/dbs, first create the directory",
        "using operating system facilities and set the correct ownership:",
        "mkdir /data/dbs",
        "chown postgres:postgres /data/dbs",
        "Then issue the tablespace creation command inside PostgreSQL:",
        "CREATE TABLESPACE dbspace LOCATION '/data/dbs';",
        "To create a tablespace owned by a different database user, use a command like this:",
        "CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';"
    ],
    "see_also": [
        {
            "name": "CREATEDATABASE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEDATABASE/7/json"
        },
        {
            "name": "CREATETABLE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATETABLE/7/json"
        },
        {
            "name": "CREATEINDEX",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEINDEX/7/json"
        },
        {
            "name": "DROPTABLESPACE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPTABLESPACE/7/json"
        },
        {
            "name": "ALTERTABLESPACE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERTABLESPACE/7/json"
        },
        {
            "name": "TABLESPACE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/TABLESPACE/7/json"
        }
    ]
}