show postgresql database schema

Viewed 896

I want to show something like this with PostgreSQL but I don't know what I must searching for

enter image description here

can you explain to me how to show something like this with PostgreSQL ?

2 Answers

The image you shared is a graphical layout of tables. PostgreSQL doesn't produce such output, but you can get the layout of individual tables by running \d <tablename> in psql. This will provide you with the list of columns, column types, constraints, primary key, foreign keys and comments.

For example:

postgres=# \d catalogue
                               Table "public.catalogue"
   Column    |  Type   | Collation | Nullable |                Default
-------------+---------+-----------+----------+---------------------------------------
 id          | integer |           | not null | nextval('catalogue_id_seq'::regclass)
 item        | name    |           |          |
 qty         | integer |           |          |
 description | text    |           |          |
Indexes:
    "catalogue_pkey" PRIMARY KEY, btree (id)

Alternatively, if you require a GUI-based solution, check out PgAdmin: https://www.pgadmin.org/

You can use dbeaver for this, using View Diagram option clicking in you schema

Related