Re: location for pg_default tablespace

From: Scott Mead <scott(dot)lists(at)enterprisedb(dot)com>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: AI Rumman <rummandba(at)gmail(dot)com>, John R Pierce <pierce(at)hogranch(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: location for pg_default tablespace
Date: 2010-01-12 06:29:48
Message-ID: d3ab2ec81001112229y2f539fa7k27d8ce47280401e7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 12, 2010 at 7:17 AM, Greg Smith <greg(at)2ndquadrant(dot)com> wrote:

> AI Rumman wrote:
>
>> I used the followings:
>> create tablespace mytabspc location '/var/lib/pgsql/data/pg_tblspc';
>> create database mydb with tablespace=mytabspc;
>> drop database mydb;
>> drop tablespace mytabspc;
>> ERROR: tablspace 'mytabspc' is not empty
>> Please tell me why?
>>
>
> You don't put things in pg_tblspace yourself; that directory is for the
> database to manage. Your tablespace should be somewhere completely outside
> of /var/lib/pgsql/data altogether.

Tablespaces in postgres are quite a bit different from Oracle. In Oracle,
you define a tablespace to be a location that uses one or more datafiles,
and everything belongs in a tablespace.

In postgres, a tablespace is not required. It is nothing more than a
directory on some filesystem that you tell postgres about so that you can
store relations in it. If you don't define a tablespace in postgres, all of
your relations are going to be located in /var/lib/pgsql/base.

That's the difference, you don't NEED a tablespace like Oracle, you'll
only use them in postgres when you're trying to store data in postgres on a
different mountpoint.

Hope this helps.

--Scott

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2010-01-12 06:30:03 Re: transaction logging in the form of SQL statements
Previous Message Greg Smith 2010-01-12 06:17:26 Re: location for pg_default tablespace