Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307951
  • 博文数量: 81
  • 博客积分: 3813
  • 博客等级: 中校
  • 技术积分: 945
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-24 18:14
文章分类

全部博文(81)

文章存档

2013年(1)

2012年(2)

2011年(54)

2010年(15)

2009年(9)

分类:

2010-07-22 15:58:43

PostgreSQL
 
使用tablespaces, at least two ways:
 
First, if the partition or volume on which the cluster was initialized runs out of space and cannot be extended, a tablespace can be created on a different partition and used until the system can be reconfigured.
 
Second, tablespaces allow an administrator to use knowledge of the usage pattern of database objects to optimize performance.
 

定义一个 tablespace, use the command, for example:
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';

NOTE: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. 
Creates a table in the tablespace space1:
CREATE TABLE foo(i int) TABLESPACE space1;

use the parameter:

	SET default_tablespace = space1;
	CREATE TABLE foo(i int);
 
TEMP TABLESPACE
   There is also a  parameter, which determines the placement of temporary tables and indexes, as well as temporary files that are used for purposes such as sorting large data sets. This can be a list of tablespace names, rather than only one, so that the load associated with temporary objects can be spread over multiple tablespaces. A random member of the list is picked each time a temporary object is to be created. 


The tablespace associated with a database is used to store the system catalogs of that database. Furthermore, it is the default tablespace used for tables, indexes, and temporary files created within the database,if no TABLESPACE clause is given and no other selection is specified by default_tablespace or temp_tablespaces (as appropriate). If a database is created without specifying a tablespace for it, it uses the same tablespace as the template database it is copied from.
Two tablespaces are automatically created by initdb. The pg_global tablespace is used for shared system catalogs. The pg_default tablespace is the default tablespace of the template1 and template0 databases (and, therefore, will be the default tablespace for other databases as well, unless overridden by a TABLESPACE clause in CREATE DATABASE).
Once created, a tablespace can be used from any database, provided the requesting user has sufficient privilege. This means that a tablespace cannot be dropped until all objects in all databases using the tablespace have been removed.
To remove an empty tablespace, use the command.
阅读(610) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~