在PostgreSQL中,OID(对象标识符)用来在整个数据库集簇中唯一地标识一个数据库对象,这个数据库对象可以是数据库、表、索引、视图、远足、类型等。
pg提供了Oid数据类型来表示OID,它实际上是一个无符号整数。
highgo=# select oid from pg_class where relname='test' ;
oid
-------
49273
49236
49233
(3 rows)
highgo=# select oid,relowner,reltype from pg_class where relname='test' ;
oid | relowner | reltype
-------+----------+---------
49273 | 10 | 49275
49236 | 10 | 49238
49233 | 10 | 49235
(3 rows)
highgo=# select * from test;
id | name
----+-------
1 | aaaaa
2 | bbbbb
(2 rows)
highgo=# select * from a.test;
id
----
4
3
5
6
(4 rows)
highgo=# select * from b.test;
id
----
2
(1 row)
[highgo@sourcedb ~]$ oid2name -V
oid2name (HighGo Database) 3.0.2
[highgo@sourcedb ~]$ oid2name -d highgo
From database "highgo":
Filenode Table Name
-----------------------------
49586 atest
49645 banji
49304 banji
49337 china
49298 edoc_todoworklist
49568 my_colors
49295 myt
49642 test
49618 test
49621 test
[highgo@sourcedb ~]$ oid2name
All databases:
Oid Database Name Tablespace
----------------------------------
13010 highgo pg_default
13005 template0 pg_default
1 template1 pg_default
49648 test pg_default
[highgo@sourcedb ~]$ oid2name -s
All tablespaces:
Oid Tablespace Name
-----------------------
1663 pg_default
1664 pg_global
[highgo@sourcedb ~]$ oid2name -d highgo -f 49621
From database "highgo":
Filenode Table Name
----------------------
49621 test
[highgo@sourcedb ~]$ oid2name -d highgo -t test -f 49621 -x
From database "highgo":
Filenode Table Name Oid Schema Tablespace
-------------------------------------------------
49642 test 49273 public pg_default
49618 test 49236 b pg_default
49621 test 49233 a pg_default
[highgo@sourcedb ~]$
pg提供了Oid数据类型来表示OID,它实际上是一个无符号整数。
highgo=# select oid from pg_class where relname='test' ;
oid
-------
49273
49236
49233
(3 rows)
highgo=# select oid,relowner,reltype from pg_class where relname='test' ;
oid | relowner | reltype
-------+----------+---------
49273 | 10 | 49275
49236 | 10 | 49238
49233 | 10 | 49235
(3 rows)
highgo=# select * from test;
id | name
----+-------
1 | aaaaa
2 | bbbbb
(2 rows)
highgo=# select * from a.test;
id
----
4
3
5
6
(4 rows)
highgo=# select * from b.test;
id
----
2
(1 row)
[highgo@sourcedb ~]$ oid2name -V
oid2name (HighGo Database) 3.0.2
[highgo@sourcedb ~]$ oid2name -d highgo
From database "highgo":
Filenode Table Name
-----------------------------
49586 atest
49645 banji
49304 banji
49337 china
49298 edoc_todoworklist
49568 my_colors
49295 myt
49642 test
49618 test
49621 test
[highgo@sourcedb ~]$ oid2name
All databases:
Oid Database Name Tablespace
----------------------------------
13010 highgo pg_default
13005 template0 pg_default
1 template1 pg_default
49648 test pg_default
[highgo@sourcedb ~]$ oid2name -s
All tablespaces:
Oid Tablespace Name
-----------------------
1663 pg_default
1664 pg_global
[highgo@sourcedb ~]$ oid2name -d highgo -f 49621
From database "highgo":
Filenode Table Name
----------------------
49621 test
[highgo@sourcedb ~]$ oid2name -d highgo -t test -f 49621 -x
From database "highgo":
Filenode Table Name Oid Schema Tablespace
-------------------------------------------------
49642 test 49273 public pg_default
49618 test 49236 b pg_default
49621 test 49233 a pg_default
[highgo@sourcedb ~]$