+ endterm="sql-createtablespace-title"> command, for
+ example:
CREATE TABLESPACE>>
+CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
+
+ The location must be an existing, empty directory that is owned by
+ the
PostgreSQL> system user. All objects subsequently
+ created within the tablespace will be stored in files underneath this
+ directory.
+
+
+
+ There is usually not much point in making more than one
+ tablespace per logical filesystem, since you can't control the location
+ of individual files within a logical filesystem. However,
+
PostgreSQL> does not enforce any such limitation, and
+ indeed it's not directly aware of the filesystem boundaries on your
+ system. It just stores files in the directories you tell it to use.
+
+
+
+ Creation of the tablespace itself must be done as a database superuser,
+ but after that you can allow ordinary database users to make use of it.
+ To do that, grant them the CREATE> privilege on it.
+
+
+ Databases, schemas, tables, and indexes can all be assigned to
particular tablespaces. To do so, a user with the CREATE>
privilege on a given tablespace must pass the tablespace name as a
parameter to the relevant command. For example, the following creates
A schema does not in itself occupy any storage (other than a system
catalog entry), so assigning a tablespace to a schema does not in itself
do anything. What this actually does is to set a default tablespace
- for tables, indexes, and sequences later created within the schema. If
+ for tables later created within the schema. If
no tablespace is mentioned when creating a schema, it inherits its
default tablespace from the current database.
- Another way to state the above rules is that when a schema, table, index
- or sequence is created without specifying a tablespace, the object
+ Another way to state the above rules is that when a schema, table, or index
+ is created without specifying a tablespace, the object
inherits its logical parent's tablespace. A schema will be created in the
- current database's tablespace; a table or sequence will be created in the
+ current database's tablespace; a table will be created in the
tablespace of the schema it is being created in; an index will be created
in the tablespace of the table underlying the index.