psql 상에서 \d, \df 같은 명령어에 대한 query문을 보려면,
psql 실행시 -E 옵션을 주면 해당 명령어의 결과와 함께 그 결과를 가져오기 위한 query문이 나옴.
그냥 실행
public=# \d
List of relations
Schema | Name | Type | Owner
---------+--------------------+----------+-----------
public | server_list | table | bloodguy
public | server_list_idx_seq | sequence | bloodguy
public | task_list | table | bloodguy
public | task_list_idx_seq | sequence | bloodguy
(4 rows)
List of relations
Schema | Name | Type | Owner
---------+--------------------+----------+-----------
public | server_list | table | bloodguy
public | server_list_idx_seq | sequence | bloodguy
public | task_list | table | bloodguy
public | task_list_idx_seq | sequence | bloodguy
(4 rows)
-E 옵션으로 실행한 psql 의 결과값 (결과를 가져오기 위한 query가 함께 나옴)
public=# \d
********* QUERY **********
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
r.rolname as "Owner"
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_roles r ON r.oid = c.relowner
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname <> 'pg_catalog'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************
List of relations
Schema | Name | Type | Owner
---------+-------------------+-----------+-----------
public | server_list | table | bloodguy
public | server_list_idx_seq | sequence | bloodguy
public | task_list | table | bloodguy
public | task_list_idx_seq | sequence | bloodguy
(4 rows)
********* QUERY **********
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
r.rolname as "Owner"
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_roles r ON r.oid = c.relowner
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname <> 'pg_catalog'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************
List of relations
Schema | Name | Type | Owner
---------+-------------------+-----------+-----------
public | server_list | table | bloodguy
public | server_list_idx_seq | sequence | bloodguy
public | task_list | table | bloodguy
public | task_list_idx_seq | sequence | bloodguy
(4 rows)
'DataBase' 카테고리의 다른 글
[PostgreSQL] DB 덤프 & 복구 (0) | 2010.01.05 |
---|---|
[PostgreSQL] COMMENT (0) | 2009.10.10 |
[PostgreSQL] integer 배열을 가져오는 서브쿼리로 조건 검색하기 (0) | 2009.10.06 |
[PostgreSQL] Excel 파일 포맷으로 덤프하기 (0) | 2009.09.24 |
[PostgreSQL] WindowsXP에 설치하기 (0) | 2009.09.22 |