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)



-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)
Posted by bloodguy
,