Обсуждение: Case sensitivity question . . .

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

Case sensitivity question . . .

От
"Peter E. Chen"
Дата:
Hey All,

I'm trying to create new databases and tables.  The database names and
tables always end up in lower case.  Is there a way to have some upper case
letters in database and table names?

Thanks for any help.

Peter


Re: Case sensitivity question . . .

От
"Gregory Wood"
Дата:
http://www7.us.postgresql.org/users-lounge/docs/7.1/user/sql-syntax.html#SQL
-SYNTAX-IDENTIFIERS

----- Excerpt -----
There is a second kind of identifier: the delimited identifier or quoted
identifier. It is formed by enclosing an arbitrary sequence of characters in
double-quotes ("). A delimited identifier is always an identifier, never a
key word. So "select" could be used to refer to a column or table named
"select", whereas an unquoted select would be taken as a key word and would
therefore provoke a parse error when used where a table or column name is
expected. The example can be written with quoted identifiers like this:

UPDATE "my_table" SET "a" = 5;

Quoted identifiers can contain any character other than a double quote
itself. This allows constructing table or column names that would otherwise
not be possible, such as ones containing spaces or ampersands. The length
limitation still applies.

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 Postgres, but "Foo" and "FOO" are different
from these three and each other. [1]
----------

That being said, I wouldn't do it unless you really need it.

Greg

----- Original Message -----
From: "Peter E. Chen" <pchen3@jhmi.edu>
To: "Postgres (General)" <pgsql-general@postgresql.org>
Sent: Wednesday, January 02, 2002 3:21 PM
Subject: [GENERAL] Case sensitivity question . . .


> Hey All,
>
> I'm trying to create new databases and tables.  The database names and
> tables always end up in lower case.  Is there a way to have some upper
case
> letters in database and table names?
>
> Thanks for any help.
>
> Peter
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


Re: Case sensitivity question . . .

От
Doug McNaught
Дата:
"Peter E. Chen" <pchen3@jhmi.edu> writes:

> Hey All,
>
> I'm trying to create new databases and tables.  The database names and
> tables always end up in lower case.  Is there a way to have some upper case
> letters in database and table names?

Put the mixed-case table names in double quotes, eg:

create table "MyTable" ("myField" integer);

Note that if you do this you will ALWAYS have to use double-quotes
around those names, as the query parser always folds case otherwise.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863

Re: Case sensitivity question . . .

От
Dave Trombley
Дата:
Peter E. Chen wrote:

>
>I'm trying to create new databases and tables.  The database names and
>tables always end up in lower case.  Is there a way to have some upper case
>letters in database and table names?
>
    You may enclose the names in quotes.

    -dj trombley
       <dtrom@bumba.net>



Re: Case sensitivity question . . .

От
"Bryan White"
Дата:
> I'm trying to create new databases and tables.  The database names and
> tables always end up in lower case.  Is there a way to have some upper
case
> letters in database and table names?

You can double quote the names.



Re: Case sensitivity question . . .

От
Brent Verner
Дата:
[2002-01-02 15:21] Peter E. Chen said:
| Hey All,
|
| I'm trying to create new databases and tables.  The database names and
| tables always end up in lower case.  Is there a way to have some upper case
| letters in database and table names?

Yes, quote the names...

  brent=# create table "A1" ( "SteakSauce" int );
  CREATE
  brent=# \d "A1"
             Table "A1"
   Attribute  |  Type   | Modifier
  ------------+---------+----------
   SteakSauce | integer |

Be aware that if you choose to use mixed case names, you must
/always/ quote them, which introduces just enough room for human
error that I'd not recommend using quoted names.

  brent=# INSERT INTO A1 VALUES (1);
  ERROR:  Relation 'a1' does not exist
  brent=# INSERT INTO "A1" VALUES (1);
  INSERT 100155 1
  brent=# SELECT * FROM A1;
  ERROR:  Relation 'a1' does not exist
  brent=# SELECT * FROM "A1";
   SteakSauce
  ------------
            1
  (1 row)


cheers.
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman