설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 73건, 최근 0 건
   

특정 테이블에 대응되는 os 화일찾기

글쓴이 : PostgresDBA 날짜 : 2014-05-20 (화) 23:30 조회 : 6385
테이블을 하나 만들고 그에 대응되는 os 상의 화일명을 찾아봅시다.
설명은 따로 하지 않겠습니다. 음미해보세요.

[postgres@pgdbserver:/opt/PostgreSQL/9.3/data/base/1]$ psql -U postgres
psql.bin (9.3.2)
Type "help" for help.

No entry for terminal type "vt100";
using dumb terminal settings.
postgres=# select oid, datname from pg_database;
  oid  |    datname     
-------+----------------
     1 | template1
 12809 | template0
 12814 | postgres
 24586 | orascope_repo
 79418 | orascope_repox
(5 rows)

postgres=# create table test(x int);
CREATE TABLE
postgres=# select relfilenode, relname from pg_class where relname='test'; 
 relfilenode | relname 
-------------+---------
      101841 | test
(1 row)

postgres=# ^D\q
[postgres@pgdbserver:/opt/PostgreSQL/9.3/data/base/12814]$ ls -l 101841
-rw------- 1 postgres postgres 0 Mar 15 00:00 101841
[postgres@pgdbserver:/opt/PostgreSQL/9.3/data/base/12814]$ 

색깔로 잘 매치해서 이해보세요.
대충 감이 오시나요?

PGAdmin 2014-06-25 (수) 22:16
oid2name 이라는 cli (command line interface)가 있습니다.
이것을 사용하시면 데이터베이스에 접속하지 않고도 해당 테이블의 oid 를 찾을 수 있습니다.

-bash-4.1$ oid2name --help
oid2name helps examining the file structure used by PostgreSQL.

Usage:
  oid2name [OPTION]...

Options:
  -d DBNAME      database to connect to
  -f FILENODE    show info for table with given file node
  -H HOSTNAME    database server host or socket directory
  -i            show indexes and sequences too
  -o OID        show info for table with given OID
  -p PORT        database server port number
  -q            quiet (don't show headers)
  -s            show all tablespaces
  -S            show system objects too
  -t TABLE      show info for named table
  -U NAME        connect as specified database user
  -V, --version  output version information, then exit
  -x            extended (show additional columns)
  -?, --help    show this help, then exit

The default action is to show all database OIDs.


PPAS를 설치하면 기본으로 생성되는 edb에 샘플 테이블인 emp 테이블의 oid를 조회합니다.

-bash-4.1$ oid2name -d edb -t emp
From database "edb":
  Filenode    Table Name
--------------- -----------------
    16477        emp
댓글주소
   

postgresdba.com