how can I find out the numeric directory name of each database in PostgreSQL 8.3

Started by Justin Yaoover 17 years ago7 messagesgeneral
Jump to latest
#1Justin Yao
justin@snooth.com

Hi,

In PostgreSQL 7.x, I can use SQL:
select datname, oid from pg_database
to find out the numeric directory name under $PGDATA/base for each
database. But it doesn't work for PostgreSQL 8.3.
Is there any way I can do it for 8.3?

Thanks,
--
Justin Yao

#2Tino Wildenhain
tino@wildenhain.de
In reply to: Justin Yao (#1)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

Hi,

Justin Yao wrote:

Hi,

In PostgreSQL 7.x, I can use SQL:
select datname, oid from pg_database
to find out the numeric directory name under $PGDATA/base for each
database. But it doesn't work for PostgreSQL 8.3.
Is there any way I can do it for 8.3?

What would you do with that name once you have it?

Tino

#3Justin Yao
justin@snooth.com
In reply to: Tino Wildenhain (#2)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

nothing special, just curious about it.
I suppose it should be able to be located by SQL.

Justin

Tino Wildenhain wrote:

Show quoted text

Hi,

Justin Yao wrote:

Hi,

In PostgreSQL 7.x, I can use SQL:
select datname, oid from pg_database
to find out the numeric directory name under $PGDATA/base for each
database. But it doesn't work for PostgreSQL 8.3.
Is there any way I can do it for 8.3?

What would you do with that name once you have it?

Tino

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Justin Yao (#1)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

Justin Yao <justin@snooth.com> writes:

In PostgreSQL 7.x, I can use SQL:
select datname, oid from pg_database
to find out the numeric directory name under $PGDATA/base for each
database. But it doesn't work for PostgreSQL 8.3.

It works for me ... what problem are you having?

regards, tom lane

#5Justin Yao
justin@snooth.com
In reply to: Tom Lane (#4)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

forget it..... I am really sorry about that.
it works for me, too.

when I did :

dbname=> \d pg_database
Table "pg_catalog.pg_database"
Column | Type | Modifiers
---------------+-----------+-----------
datname | name | not null
datdba | oid | not null
encoding | integer | not null
datistemplate | boolean | not null
datallowconn | boolean | not null
datconnlimit | integer | not null
datlastsysoid | oid | not null
datfrozenxid | xid | not null
dattablespace | oid | not null
datconfig | text[] |
datacl | aclitem[] |
Indexes:
"pg_database_datname_index" UNIQUE, btree (datname), tablespace
"pg_global"
"pg_database_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
Triggers:
pg_sync_pg_database AFTER INSERT OR DELETE OR UPDATE ON pg_database
FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger()
Tablespace: "pg_global"

I didn't find the Column "oid", I take granted to think it may not work,
but I didn't issue a command to have a try.

Really sorry about that.

But the question is, why there's no column named "oid" and it still works?

Thanks,
Justin

Tom Lane wrote:

Show quoted text

Justin Yao <justin@snooth.com> writes:

In PostgreSQL 7.x, I can use SQL:
select datname, oid from pg_database
to find out the numeric directory name under $PGDATA/base for each
database. But it doesn't work for PostgreSQL 8.3.

It works for me ... what problem are you having?

regards, tom lane

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Justin Yao (#5)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

Justin Yao <justin@snooth.com> writes:

But the question is, why there's no column named "oid" and it still works?

\d doesn't show system columns.
http://www.postgresql.org/docs/8.3/static/ddl-system-columns.html

regards, tom lane

#7Justin Yao
justin@snooth.com
In reply to: Tom Lane (#6)
Re: how can I find out the numeric directory name of each database in PostgreSQL 8.3

thanks so much!

Tom Lane wrote:

Show quoted text

Justin Yao <justin@snooth.com> writes:

But the question is, why there's no column named "oid" and it still works?

\d doesn't show system columns.
http://www.postgresql.org/docs/8.3/static/ddl-system-columns.html

regards, tom lane