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?
To get the column name of a table we use sp_help with the name of the object or table name. sp_columns returns all the column names of the object. The following query will return the table's column names: sp_columns @table_name = 'News'
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With