61

Here' my current state.

Eonil=# \d+
                       List of relations
 Schema |    Name    | Type  | Owner |    Size    | Description 
--------+------------+-------+-------+------------+-------------
 public | TestTable1 | table | Eonil | 8192 bytes | 
(1 row)

Eonil=# \d+ TestTable1
Did not find any relation named "TestTable1".
Eonil=# 

What is the problem and how can I see the table definition?

eonil
  • 83,476
  • 81
  • 317
  • 516

1 Answers1

106

Postgres psql needs escaping for capital letters.

Eonil=# \d+ "TestTable1"

So this works well.

Eonil=# \d+ "TestTable1"
                   Table "public.TestTable1"
 Column |       Type       | Modifiers | Storage  | Description 
--------+------------------+-----------+----------+-------------
 ID     | bigint           | not null  | plain    | 
 name   | text             |           | extended | 
 price  | double precision |           | plain    | 
Indexes:
    "TestTable1_pkey" PRIMARY KEY, btree ("ID")
    "TestTable1_name_key" UNIQUE CONSTRAINT, btree (name)
Has OIDs: no

Eonil=# 
eonil
  • 83,476
  • 81
  • 317
  • 516
  • 9
    Unquoted identifiers (such as table and column names) are folded to lower case in PostgreSQL, note that the standard specifies that they should be upcased so PostgreSQL is non-standard here. If you need your identifiers in a specific case or if they contain whitespace then you **must** double quote them **everywhere**. The recommended practice is to use lower case identifiers with words separated by underscores in PostgreSQL, that way you don't have to care about quoting or case issues. – mu is too short Mar 06 '13 at 03:07
  • Thanks for explanation. Anyway, as an application programmer - not a professional DBA - I like this explicit behavior and it's even better if it spits error on these kind of small differences. – eonil Mar 06 '13 at 03:24