How to get the physical locations of tables, views, functions etc of Postgresql in Windows & Linux?
Hi there! I'm interested to get the physical locations of tables, views, functions, data/content available in the tables of PostgreSQL in Linux OS. I've a scenario that PostgreSQL could be installed in SD-Card facility and Hard-Disk. If I've tables, views, functions, data in SD, I want to get the physical locations of the same and merge/copy into my hard-disk whenever I wish to replace the storage space. I hope the storage of database should be in terms of plain files architecture.
Also, can I able to see the contents by opening its files? I mean, can I able to access it? Please help me on this. Thanks!
________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.
-----------------------------------------------------------------------------------------------------------------------
On Thu, May 3, 2012 at 6:52 PM, Siva Palanisamy <siva_p@hcl.com> wrote:
Hi there! I'm interested to get the physical locations of tables, views,
functions, data/content available in the tables of PostgreSQL in Linux OS.
I've a scenario that PostgreSQL could be installed in SD-Card facility and
Hard-Disk. If I've tables, views, functions, data in SD, I want to get the
physical locations of the same and merge/copy into my hard-disk whenever I
wish to replace the storage space. I hope the storage of database should be
in terms of plain files architecture.
You first step should start from $PGDATA/base/, you find OID's as
directories which are related to each database of your cluster. In OID's
directory, you find all the objects ID's for Tables/indexes/view etc.,
To know the object id, you can use a system defined function.
postgres=# select pg_relation_filepath('foo');
pg_relation_filepath
----------------------
base/12780/16407
(1 row)
12780, is database OID.
For moving objects from one drive to other, you need to use tablespaces.
http://www.postgresql.org/docs/9.1/static/sql-createtablespace.html
****
Also, can I able to see the contents by opening its files? I mean, can I
able to access it? Please help me on this. Thanks!******
You cannot know the contents in files, unless u are good hacker :)
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
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.
From: Raghavendra [mailto:raghavendra.rao@enterprisedb.com]
Sent: Thursday, May 03, 2012 7:09 PM
To: Siva Palanisamy
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to get the physical locations of tables, views, functions etc of Postgresql in Windows & Linux?
On Thu, May 3, 2012 at 6:52 PM, Siva Palanisamy <siva_p@hcl.com<mailto:siva_p@hcl.com>> wrote:
Hi there! I'm interested to get the physical locations of tables, views, functions, data/content available in the tables of PostgreSQL in Linux OS. I've a scenario that PostgreSQL could be installed in SD-Card facility and Hard-Disk. If I've tables, views, functions, data in SD, I want to get the physical locations of the same and merge/copy into my hard-disk whenever I wish to replace the storage space. I hope the storage of database should be in terms of plain files architecture.
You first step should start from $PGDATA/base/, you find OID's as directories which are related to each database of your cluster. In OID's directory, you find all the objects ID's for Tables/indexes/view etc.,
To know the object id, you can use a system defined function.
postgres=# select pg_relation_filepath('foo');
pg_relation_filepath
----------------------
base/12780/16407
(1 row)
12780, is database OID.
For moving objects from one drive to other, you need to use tablespaces.
http://www.postgresql.org/docs/9.1/static/sql-createtablespace.html
Also, can I able to see the contents by opening its files? I mean, can I able to access it? Please help me on this. Thanks!
You cannot know the contents in files, unless u are good hacker :)
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.
-----------------------------------------------------------------------------------------------------------------------
On Fri, May 4, 2012 at 3:31 PM, Siva Palanisamy <siva_p@hcl.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/