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


총 게시물 73건, 최근 0 건
   

유저명와 스키마간의 매칭

글쓴이 : PostgresDBA 날짜 : 2013-07-02 (화) 13:32 조회 : 6127
postgres=# select * from pg_namespace;  -- oid 값이 안보이네요.
      nspname       | nspowner |               nspacl
--------------------+----------+-------------------------------------
 pg_toast           |       10 |
 pg_temp_1          |       10 |
 pg_toast_temp_1    |       10 |
 pg_catalog         |       10 | {postgres=UC/postgres,=U/postgres}
 public             |       10 | {postgres=UC/postgres,=UC/postgres}
 information_schema |       10 | {postgres=UC/postgres,=U/postgres}
(6 rows)


postgres=# select oid, * from pg_namespace; 
  oid  |      nspname       | nspowner |               nspacl
-------+--------------------+----------+-------------------------------------
    99 | pg_toast           |       10 |
 11194 | pg_temp_1          |       10 |
 11195 | pg_toast_temp_1    |       10 |
    11 | pg_catalog         |       10 | {postgres=UC/postgres,=U/postgres}
  2200 | public             |       10 | {postgres=UC/postgres,=UC/postgres}
 11459 | information_schema |       10 | {postgres=UC/postgres,=U/postgres}
(6 rows)

참고) pg_namespace 

Name Type References Description
oid oid   Row identifier (hidden attribute; must be explicitly selected)
nspname name   Name of the namespace
nspowner oid pg_authid.oid Owner of the namespace
nspacl aclitem[]   Access privileges; see GRANT and REVOKE for details

아래 쿼리로 스키마와 해당 스키마 owner 를 매칭시킬수 있습니다.

postgres=# select  x.oid schema_id, x.nspname schema_name, x.nspowner userid, y.
usename username from pg_namespace x inner join pg_user y 
on x.nspowner=y.usesys
id;
 schema_id |    schema_name     | userid | username
-----------+--------------------+--------+----------
        99 | pg_toast           |     10 | postgres
     11194 | pg_temp_1          |     10 | postgres
     11195 | pg_toast_temp_1    |     10 | postgres
        11 | pg_catalog         |     10 | postgres
      2200 | public             |     10 | postgres
     11459 | information_schema |     10 | postgres
(6 rows)


postgres=#

   

postgresdba.com