为什么看不到表的列名? [英] 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的关系。
等一下?!测试不是只显示在关系列表下吗?
Wait a minute?! Did not Test just show up under "List of Relations"? What's going on here?
推荐答案
PostgreSQL默认将未加引号的标识符(例如表名和列名)转换为小写。该标准说,标识符应该规范化为大写,但这在这里并不重要。因此,当您这样说:
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认为与 \d测试
相同。您可能有一个用引号引起来的表:
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"
这篇关于为什么看不到表的列名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!