バージョンごとのドキュメント一覧

CREATE TABLESPACE

CREATE TABLESPACE <refpurpose>define a new tablespace</refpurpose> — 新しいテーブル空間を定義する

概要

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

説明

<title>Description</title>

<command>CREATE TABLESPACE</command> registers a new cluster-wide tablespace. The tablespace name must be distinct from the name of any existing tablespace in the database cluster. CREATE TABLESPACEはクラスタ全体で使用できるテーブル空間を新規に登録します。 このテーブル空間名は、データベースクラスタ内の既存のテーブル空間名と異なるものでなければなりません。

A tablespace allows superusers to define an alternative location on the file system where the data files containing database objects (such as tables and indexes) can reside. スーパーユーザはテーブル空間を使用することで、データベースオブジェクト(テーブルやインデックスなど)が入ったデータファイルを格納できる、ファイルシステム上の別の場所を定義できます。

A user with appropriate privileges can pass <replaceable class="parameter">tablespace_name</replaceable> to <command>CREATE DATABASE</command>, <command>CREATE TABLE</command>, <command>CREATE INDEX</command> or <command>ADD CONSTRAINT</command> to have the data files for these objects stored within the specified tablespace. 適切な権限を持つユーザは、CREATE DATABASECREATE TABLECREATE INDEXADD CONSTRAINTコマンドにtablespace_nameを渡すことで、これらのオブジェクトを指定したテーブル空間に格納することができます。

警告

A tablespace cannot be used independently of the cluster in which it is defined; see <xref linkend="manage-ag-tablespaces"/>. テーブル空間は、それが定義されているクラスタと独立して使うことはできません。 23.6を参照してください。

パラメータ

<title>Parameters</title>
tablespace_name

The name of a tablespace to be created. The name cannot begin with <literal>pg_</literal>, as such names are reserved for system tablespaces. 作成するテーブル空間の名前です。 pg_から始まる名前はシステムのテーブル空間用に予約されているので使用することはできません。

user_name

The name of the user who will own the tablespace. If omitted, defaults to the user executing the command. Only superusers can create tablespaces, but they can assign ownership of tablespaces to non-superusers. テーブル空間を所有するユーザの名前です。 省略時はデフォルトでコマンドを実行したユーザとなります。 テーブル空間を作成できるのはスーパーユーザのみですが、テーブル空間の所有権を非スーパーユーザに割り当てることは可能です。

directory

The directory that will be used for the tablespace. The directory must exist (<command>CREATE TABLESPACE</command> will not create it), should be empty, and must be owned by the <productname>PostgreSQL</productname> system user. The directory must be specified by an absolute path name. テーブル空間用に使用するディレクトリです。 このディレクトリは存在していなければなりませんし(CREATE TABLESPACE はディレクトリを作成しません)、空であるべきです。また、PostgreSQLのシステムユーザが所有していなければなりません。 このディレクトリは絶対パス名で指定する必要があります。

tablespace_option

A tablespace parameter to be set or reset. Currently, the only available parameters are <varname>seq_page_cost</varname>, <varname>random_page_cost</varname>, <varname>effective_io_concurrency</varname> and <varname>maintenance_io_concurrency</varname>. Setting these values for a particular tablespace will override the planner's usual estimate of the cost of reading pages from tables in that tablespace, and the executor's prefetching behavior, as established by the configuration parameters of the same name (see <xref linkend="guc-seq-page-cost"/>, <xref linkend="guc-random-page-cost"/>, <xref linkend="guc-effective-io-concurrency"/>, <xref linkend="guc-maintenance-io-concurrency"/>). This may be useful if one tablespace is located on a disk which is faster or slower than the remainder of the I/O subsystem. 値を設定あるいはリセットするテーブル空間のパラメータです。 現在、利用可能なパラメータはseq_page_costrandom_page_costeffective_io_concurrencymaintenance_io_concurrencyだけです。 特定のテーブル空間について、その値を設定すると、プランナがそのテーブル空間内のテーブルからページを読み込むコストの通常の推定値やエグゼキュータの先読みの振る舞いについて、通常参照する同じ名前の設定パラメータ(seq_page_costrandom_page_costeffective_io_concurrencymaintenance_io_concurrencyを参照)よりも優先します。 テーブル空間が、他のI/Oサブシステムより高速あるいは低速なディスク上にある時は、これが有効でしょう。

注釈

<title>Notes</title>

<command>CREATE TABLESPACE</command> cannot be executed inside a transaction block. トランザクションブロック内でCREATE TABLESPACEを実行することはできません。

<title>Examples</title>

To create a tablespace <literal>dbspace</literal> at file system location <literal>/data/dbs</literal>, first create the directory using operating system facilities and set the correct ownership: ファイルシステムの/data/dbsにテーブル空間dbspaceを作成するためには、まずオペレーティングシステムの機能を使ってディレクトリを作成し、正しい所有権を設定します。

mkdir /data/dbs
chown postgres:postgres /data/dbs

Then issue the tablespace creation command inside <productname>PostgreSQL</productname>: 次に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';

互換性

<title>Compatibility</title>

<command>CREATE TABLESPACE</command> is a <productname>PostgreSQL</productname> extension. CREATE TABLESPACEPostgreSQLの拡張です。

関連項目

<title>See Also</title> CREATE DATABASE, CREATE TABLE, CREATE INDEX, DROP TABLESPACE, ALTER TABLESPACE