Re: PostgreDB stores table name is lower case

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: PostgreDB stores table name is lower case
Дата
Msg-id aad4c17d-09a8-2525-23fe-c745d0c6ba27@aklaver.com
обсуждение исходный текст
Ответ на PostgreDB stores table name is lower case  ("王波" <853372309@qq.com>)
Список pgsql-general
On 11/23/2016 11:52 PM, 王波 wrote:
> Hello :
>
>         I'am a  Postgre fan.
>         Now, I have a problem, the table name is stored in lower case ,
> but i want to change it into  upper case. Can i have a simple method?
> Such as modify a parameter.

https://www.postgresql.org/docs/9.5/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

"Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For
example,the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different
fromthese three and each other. (The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL
standard,which says that unquoted names should be folded to upper case. Thus, foo should be equivalent to "FOO" not
"foo"according to the standard. If you want to write portable applications you are advised to always quote a particular
nameor never quote it.)" 

There is no parameter to set. If you want upper case names then you need to quote them:

test[5432]=# create table FOLD_LOWERCASE ();
CREATE TABLE
test[5432]=# create table "QUOTE_UPPERCASE" ();
CREATE TABLE

test[5432]=# \d fold_lowercase
Table "public.fold_lowercase"
 Column | Type | Modifiers
--------+------+-----------

test[5432]=# \d FOLD_LOWERCASE
Table "public.fold_lowercase"
                                     
 Column | Type | Modifiers
                                     
--------+------+-----------

test[5432]=# \d QUOTE_UPPERCASE
                   
Did not find any relation named "QUOTE_UPPERCASE".

test[5432]=# \d quote_uppercase
                                     
Did not find any relation named "quote_uppercase".
                                     

test[5432]=# \d "QUOTE_UPPERCASE"
                                     
Table "public.QUOTE_UPPERCASE"
                                     
 Column | Type | Modifiers
                                     
--------+------+-----------

The above also shows what happens when you quote, you are committed
to that case.

If you still want to do this then:

test[5432]=# ALTER table fold_lowercase rename to "MAKE_UPPERCASE";
ALTER TABLE

test[5432]=# \d "MAKE_UPPERCASE"
Table "public.MAKE_UPPERCASE"
 Column | Type | Modifiers
--------+------+-----------





>
>         Thank you!
>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: Query regarding deadlock
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PostgreDB stores table name is lower case