Understanding built-in backslash commands

You want to know just how \d works

Solution

Start psql with the -E option then try \d ref.

Discussion

You might also want to look at the code for pgAccess or phpPgAdmin - two tools that let you administer a Postgres database in a more visual manner (search on freshmeat.net for details).