All Products
Search
Document Center

PolarDB:CREATE TABLESPACE

Last Updated:Mar 28, 2026

CREATE TABLESPACE registers a new cluster-wide tablespace.

Important

PolarDB for Oracle does not support user-defined tablespaces. Neither privileged accounts nor standard accounts are permitted to create tablespaces. You can run CREATE TABLESPACE and reference a tablespace by name in CREATE DATABASE, CREATE TABLE, CREATE INDEX, and ADD CONSTRAINT, but objects are always stored in the pg_default tablespace. A NOTICE message is returned when you specify a tablespace for an object.

Prerequisites

Before you begin, ensure that you have:

  • The polar_superuser role

Synopsis

CREATE TABLESPACE tablespace_name
    [ OWNER { new_owner | CURRENT_USER | SESSION_USER } ]
    LOCATION 'directory'
    [ WITH ( tablespace_option = value [, ... ] ) ]

Parameters

ParameterDescription
tablespace_nameName of the tablespace. Cannot start with pg_.
OWNEROwner of the tablespace. Defaults to the user running the statement. Only polar_superuser can run this statement.
directoryAbsolute path to an existing, empty directory for the tablespace. The directory must be owned by the PolarDB system user. CREATE TABLESPACE does not create the directory.
tablespace_optionOne or more tablespace-level cost parameters. Accepted values: seq_page_cost, random_page_cost, effective_io_concurrency, maintenance_io_concurrency. These override the query planner's default cost estimates and prefetch behavior for this tablespace, useful when the tablespace resides on a disk with different I/O characteristics from the rest of the system.

Usage notes

  • CREATE TABLESPACE cannot run inside a transaction block.

  • Tablespaces are only supported on systems that support symbolic links.

  • A tablespace cannot be used independently of the cluster in which it is defined.

  • A privileged account can specify a tablespace when creating objects, but objects are stored in pg_default and a NOTICE message is returned. Standard accounts cannot specify a tablespace at all.

Examples

The following steps create a tablespace, verify it in the system catalog, and show the behavior when assigning it to a table.

  1. Create a tablespace:

    CREATE TABLESPACE test_tablespace LOCATION '/';
  2. Verify that the tablespace appears in the pg_tablespace system catalog:

    SELECT spcname FROM pg_tablespace;

    Expected output:

         spcname
    -----------------
     pg_default
     pg_global
     test_tablespace
  3. Create a table and assign it to the tablespace:

    CREATE TABLE test_table(a int) TABLESPACE test_tablespace;

    Expected output:

    NOTICE:  User defined tablespace is not supported, The tablespace set by the user will be ignored
    CREATE TABLE

    The table is created successfully, but is stored in pg_default, not test_tablespace.