Re: Problems when copy data from dump file

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Problems when copy data from dump file
Дата
Msg-id 4A7A87F1.60904@archonet.com
обсуждение исходный текст
Ответ на Re: Problems when copy data from dump file  ("Klas Stockhem" <Klas.Stockhem@benders.se>)
Список pgsql-sql
Klas Stockhem wrote:> Does the php engine interpret the big P like a small one?

It's not PHP, but PostgreSQL itself. All names in PostgreSQL are case 
insensitive unless you double-quote them. PostgreSQL actually translates 
everything to lower-case internally.

CREATE TABLE1 ...;    -- gives "table1"
CREATE "TABLE2" ...;  -- gives "TABLE2"

SELECT * FROM table1   -- works
SELECT * FROM TABLE1   -- works
SELECT * FROM TaBlE1   -- works
SELECT * FROM "table1" -- works
SELECT * FROM "TABLE1" -- FAILS, actually "table1"
SELECT * FROM table2   -- FAILS, looks for "table2"
SELECT * FROM TABLE2   -- FAILS, still looking for "table2"
SELECT * FROM "TABLE2" -- works

So - if you double-quote a table-name (or function or schema name) when 
you create it, you should always double-quote it when using it. I'm 
guessing something added double-quotes for you when you created the schema.
> Is it recommended to always have small letters in schema names?

Personally, I do. I think it looks neater.
> How do I make so I not must type the schema name in every sql query?> The best would be if I just can type the table
name.

There is a variable called "search_path" which controls what schemas are 
checked for tables, functions etc. If you have two tables with the same 
name but different schemas you'll need to use the <schema>.<table> 
format though.

SET search_path = public2,public;
ALTER USER myuser SET search_path = ...
ALTER DATABASE mydb SET search_path = ...

--   Richard Huxton  Archonet Ltd


В списке pgsql-sql по дате отправления:

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: two records per row from query
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Problems when copy data from dump file