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!

0

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.