Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

CREATE TABLESPACE

Name

CREATE TABLESPACE -- define a new tablespace

Synopsis

CREATE TABLESPACE 
tablespacename
 [ OWNER 
username
 ] LOCATION '
directory
'

Description

CREATE TABLESPACE registers a new cluster-wide tablespace. The tablespace name must be distinct from the name of any existing tablespace in the database cluster.

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) may reside.

A user with appropriate privileges can pass tablespacename to CREATE DATABASE, CREATE TABLE, CREATE INDEX or ADD CONSTRAINT to have the data files for these objects stored within the specified tablespace.

Parameters

tablespacename

The name of a tablespace to be created. The name cannot begin with pg_, as such names are reserved for system tablespaces.

username

The name of the user who will own the tablespace. If omitted, defaults to the user executing the command. Only superusers may 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 be empty and must be owned by the PostgreSQL system user. The directory must be specified by an absolute path name.

Notes

Tablespaces are only supported on systems that support symbolic links.

Examples

Create a tablespace dbspace at /data/dbs:

CREATE TABLESPACE dbspace LOCATION '/data/dbs';

Create a tablespace indexspace at /data/indexes owned by user genevieve:

CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';

Compatibility

CREATE TABLESPACE is a PostgreSQL extension.


 
 
  Published courtesy of The PostgreSQL Global Development Group Design by Interspire