Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

postgresql - Why can't I see the column names of a table?

So I made some tables programatically and I want to verify it's structure is what I think it is.

>Rocko=# c Rocko
Password for user Rocko:
psql (8.4.4, server 8.4.8)
You are now connected to database "Rocko".
Rocko=# d
            List of relations
 Schema |     Name     |   Type   | Owner
--------+--------------+----------+-------
 public | Email        | table    | Rocko
 public | Email_id_seq | sequence | Rocko
 public | Test         | table    | Rocko
 public | Test_id_seq  | sequence | Rocko
 public | User         | table    | Rocko
 public | User_id_seq  | sequence | Rocko
(6 rows)

So, for example, I want to see the columns in Test.

Rocko=# d Test

Did not find any relation named "Test".

Wait a minute?! Did not Test just show up under "List of Relations"? What's going on here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

PostgreSQL converts unquoted identifiers (such as table and column names) to lower case by default; the standard says that identifiers are supposed to be normalized to upper case but that's not important here. So, when you say this:

d Test

PostgreSQL considers that the same as d test. You probably have a table that was created with a quoted name:

create table "Test" ( ...

so that its name is case sensitive and must be quoted (with double quotes) every time it is referenced. So try quoting the name:

d "Test"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...