Describe the columns of a table
Read-only
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Prints the column names, types, nullability, and defaults for a table so you understand its schema before writing queries or modifications.
postgresqlschemacolumnsinspect
Parameters
Name of the table to inspect.
Commands
Show column definitions, indexes, and constraints for the table
psql -c "\d <table_name>"Verification
psql -c "\d <table_name>"A detailed breakdown of columns, types, and constraints is printed.
Undo
Not undoable
This recipe only reads catalog metadata and changes nothing.
Pitfalls
- The table must exist in the search path; use schema.table notation if the table is not in public.
- A view with the same name is also described; check the "View" heading in the output.
- Missing privileges on the table will produce a permission-denied error.