Sunday, November 6, 2011

Postgresql - Database object identifier (OID)

This post is associated with the other post where I described the error:

ERROR: could not read block 18875 of relation base/105574/105673: read only 0 of 8192 bytesERROR:

It turns out that the number 105574 refers to the database object identifier (database OID), which can be queried with something like this:

[sourcecode language="sql"]

postgres=# select * from pg_database where oid = 105574;
-[ RECORD 1 ]-+------------
datname       | dw_ifrembi
datdba        | 10
encoding      | 6
datcollate    | es_MX.UTF-8
datctype      | es_MX.UTF-8
datistemplate | f
datallowconn  | t
datconnlimit  | -1
datlastsysoid | 11563
datfrozenxid  | 648
dattablespace | 1663
datconfig     |
datacl        |

[/sourcecode]

The funny thing is that the OID is not displayed in the view, so the query can be tweak to something like:

[sourcecode language="sql"]

postgres=# select oid,* from pg_database where oid = 105574;
-[ RECORD 1 ]-+------------
oid           | 105574
datname       | dw_ifrembi
datdba        | 10
encoding      | 6
datcollate    | es_MX.UTF-8
datctype      | es_MX.UTF-8
datistemplate | f
datallowconn  | t
datconnlimit  | -1
datlastsysoid | 11563
datfrozenxid  | 648
dattablespace | 1663
datconfig     |
datacl

[/sourcecode]

No comments:

Post a Comment