Обсуждение: PostgreDB stores table name is lower case

Поиск
Список
Период
Сортировка

PostgreDB stores table name is lower case

От
"王波"
Дата:
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.
      
        Thank you!

  

Re: PostgreDB stores table name is lower case

От
Gavin Flower
Дата:
On 24/11/16 20:52, 王波 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.
>         Thank you!
>
>
>
Why?

I can't see any practical benefit!


Cheers,
Gavin



Re: PostgreDB stores table name is lower case

От
Adrian Klaver
Дата:
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


Re: PostgreDB stores table name is lower case

От
Tom Lane
Дата:
"=?gb18030?B?zfWyqA==?=" <853372309@qq.com> writes:
>         Now, I have a problem, the table name is stored in lower case , but i want to change it into  upper case. Can
ihave a simple method? Such as modify a parameter. 

No.

We have looked into making that configurable, and the conclusion was that
(a) it would be an enormous amount of work, and (b) it would break huge
amounts of client-side code that expects the current behavior.  So it's
not going to happen.  There are discussions about this in the mailing list
archives if you want more detail.

            regards, tom lane