Re: Problem with tables and columns names

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: Gabriel Filipiak <gabriel(dot)filipiak(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with tables and columns names
Date: 2011-12-19 10:34:24
Message-ID: CAEV0TzB-ji2z0GJkwOze7kkbPGECEczYMWGwYFL12ECUr7KD4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Dec 19, 2011 at 12:16 AM, Gabriel Filipiak <
gabriel(dot)filipiak(at)gmail(dot)com> wrote:

> Hi,
>
> so I am working on PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled
> by gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit.
>
> It seems that i can't give a table name for example testTable it has to be
> test_table, because I can't access it via psql is that right or am I doing
> something wrong? The same thing for columns. Can anyone give me a hint
> about that?
>
> What is really confusing is that I can access those tables and columns via
> SQLAlchemy.
>

Are you creating your table within a schema that is not in your
search_path? Perhaps SQLAlchemy is providing the fully qualified name but
your query in psql is not? The other option is case-sensitivity

table and column names should not be case sensitive unless you quote the
names in the create statement, in which case, you must always quote them
and capitalize them in the same way.

create table myschema.testtable (column1 int); -- no quotes means
case-insensitive table and column name

should work with a query like this:

select * from myschema.TeStTaBlE

but

create table "mySchema"."TestTable" ("Column1" int) -- quotes forces case
sensitivity

will only work with queries like this:

select "Column1" from "mySchema"."TestTable"

but won't work with a query like this:

select Column1 from mySchema.TestTable

without the quotes, postgres won't recognize table and column names that
were quoted at creation, even though they are capitalized in the same way.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Maurício Cruz 2011-12-27 11:45:06 Call a external app on postgreSQL start-up (windows)
Previous Message Andreas Kretschmer 2011-12-19 08:26:35 Re: Problem with tables and columns names