From: | Raghavendra <raghavendra(dot)rao(at)enterprisedb(dot)com> |
---|---|
To: | Siva Palanisamy <siva_p(at)hcl(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to get the physical locations of tables, views, functions etc of Postgresql in Windows & Linux? |
Date: | 2012-05-04 12:03:04 |
Message-ID: | CA+h6Ahhuovt0mmE0wMZkvFyRybX8ULbvr3ZWTvCrS9a5=8UwfA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, May 4, 2012 at 3:31 PM, Siva Palanisamy <siva_p(at)hcl(dot)com> wrote:
> Hi Raghavendra,****
>
> ** **
>
> Is it sure that we can copy only the data of Postgresql from one disk to
> other seamlessly and then I can reuse the content without any hassle? If
> so, tablespace is what I should create first?****
>
> Please clarify me on this.****
>
> ** **
>
> Thanks & Regards,****
>
> Siva.****
>
> **
>
Yes, using tablespace, you can move object files across disks. Here is
small example, I have done on my local box but you can tweak as per your
tablespace locations.
First I place object in one tablespace and moved it another tablespace.
postgres=# create tablespace space1 location '/opt/PostgreSQL/9.1/tspace';
CREATE TABLESPACE
postgres=# create table foo(id int) tablespace space1;
CREATE TABLE
postgres=# \d foo
Table "public.foo"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
Tablespace: "space1"
postgres=# insert into foo select generate_series(1,10000);
INSERT 0 10000
postgres=# \dt+ foo
List of relations
Schema | Name | Type | Owner | Size | Description
--------+------+-------+----------+--------+-------------
public | foo | table | postgres | 384 kB |
(1 row)
postgres=# select pg_tablespace_size('space1');
pg_tablespace_size
--------------------
397312
(1 row)
Now create a new one and move it.
postgres=# create tablespace new_space location
'/opt/PostgreSQL/9.1/newspace';
CREATE TABLESPACE
postgres=# alter table foo set tablespace new_space;
ALTER TABLE
postgres=# \d foo
Table "public.foo"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
Tablespace: "new_space"
postgres=# select pg_tablespace_size('new_space');
pg_tablespace_size
--------------------
397312
(1 row)
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2012-05-04 13:04:33 | Re: Re: "OLD." || myColumnNameVar (How to generically access columns in a trigger's OLD or NEW records) |
Previous Message | Siva Palanisamy | 2012-05-04 10:01:59 | Re: How to get the physical locations of tables, views, functions etc of Postgresql in Windows & Linux? |