0

So I'm very new to PostgreSQL (and SQL as a whole) and I'm trying to find a way to view all attributes of a table. For example, say you have a table called "movies", I would like to see what attributes it has (e.g. movie_name, release_year).

I'm sure there is a simple command for it, but I couldn't find it.

Thanks in advance for any help!

GMB
  • 216,147
  • 25
  • 84
  • 135
JakeDrone
  • 173
  • 1
  • 9

1 Answers1

2

Assuming that by attributes you mean columns, a standard approach uses system view information_schema.columns:

select column_name, datatype 
from information_schema.columns 
where table_name = 'mytable'

From a PSQL command line, you can also use \d (which stands for describe):

# \d mytable
GMB
  • 216,147
  • 25
  • 84
  • 135