Question

I have successfully created a table in pgAdmin which generated the code:

CREATE TABLE public."Test3"
(
    "PID" integer,
    "Name" character varying(20),
    PRIMARY KEY ("PID")
)

TABLESPACE pg_default;

ALTER TABLE public."Test3"
    OWNER to postgres;

However when I try to query the table with:

Select * from Test3;

I get the error:

ERROR:  relation "test3" does not exist 
LINE 1: Select * from Test3;
                      ^ 
SQL state: 42P01 Character: 15

Same thing happens if I leave out the TABLESPACE line. Same thing happens if I try to query a table after importing rows from a .csv file. Seems like I must be missing something obvious.

Edit: I am trying to create the table in a database named "ABR"

Was it helpful?

Solution

PostgreSQL implicitly converts all the SQL that you enter into lower case, unless you wrap things in double-quotes in which case you have to get the case exactly right.

Wherever possible, you should avoid needing quotes or other wrapper characters, i.e. don't use special characters in identifier names. It will only come back to bite you.

create table public.test3
( pid integer
, name character varying(20) 
, primary key (pid)
)

OTHER TIPS

The quotes, my friend, don't forget the quotes.

Select * from "Test3";
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top