How to View Schema in PostgreSQL

Galaxy Glossary

How do I view a schema in PostgreSQL?

Shows all schemas, tables, and columns using psql meta-commands or catalog views.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

How to View Schema in PostgreSQL

Need to inspect a database structure fast? PostgreSQL offers psql meta-commands and catalog queries to list schemas, tables, and columns with precision.

What commands show existing schemas?

In psql, run \dn to list every non-system schema. Add \dn+ for owner, ACL, and description details.

How can I list tables inside a schema?

Use \dt schema_name.* to display tables for the chosen schema.Swap \dt with \dm, \ds, or \dv for other object types.

Which SQL query reveals schema metadata?

Query information_schema.tables or pg_catalog.pg_namespace when scripting or using a GUI that lacks meta-commands.

Example: fetch all user schemas

SELECT nspname AS schema
FROM pg_catalog.pg_namespace
WHERE nspname NOT LIKE 'pg_%'
AND nspname <> 'information_schema'
ORDER BY 1;

How do I describe table columns within a schema?

Run \d schema_name.table_name in psql or query information_schema.columns filtering by table_schema and table_name.

Best practices for browsing schemas

Filter system schemas, script frequent catalog queries, and combine meta-commands with SQL for automation.

Common mistakes to avoid

Missing the dot: Typing \dt schema_name* fails.Always add .* after the schema.

Lacking privileges: Without the USAGE right on a schema, its objects stay hidden. Request grants or switch roles.

Need a GUI?

Editors like Galaxy, TablePlus, or pgAdmin visualize schemas instantly, reducing manual catalog queries.

.

Why How to View Schema in PostgreSQL is important

How to View Schema in PostgreSQL Example Usage


-- Show tables in the analytics schema
\dt analytics.*

-- SQL alternative
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'analytics'
ORDER BY 1;

How to View Schema in PostgreSQL Syntax


-- psql meta-commands
\dn[+]                         -- list schemas
\dt schema.*                   -- list tables in schema
\d schema.table                -- describe table columns

-- SQL catalog queries
SELECT *
FROM information_schema.tables
WHERE table_schema = 'public';

SELECT nspname
FROM pg_namespace;

Common Mistakes

Frequently Asked Questions (FAQs)

How do I list only user-defined schemas?

Query pg_namespace and exclude names starting with pg_ and information_schema.

Can I see schema descriptions?

Add a plus sign: \dn+. The description column shows comments added with COMMENT ON SCHEMA.

How do I search tables across all schemas?

Run \dt *.* in psql or query information_schema.tables without filtering table_schema.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.