[DB-SIG] Quoting table and column names

Magnus Lycka magnus@thinkware.se
Thu, 20 Jun 2002 02:04:43 +0200


At 14:18 2002-06-19 -0700, Ryan Weisenberger wrote:
>Is it safe to ALWAYS quote table names and column names in SQL=20
>statements?  My python app queries against several different kinds of=20
>databases, most notably Oracle 8 and 9, MS SQL Server 2000, and=20
>Sybase.  When table and column names contain spaces or characters (':' or=
=20
>'-'), I surround them with double quotes.  So is it safe to always do=20
>this?  I thought at one time I discovered that some dbs don't like this.

If my memory serves me right, at least some RDBMS
consider case to be signicant in quoted strings.
So
select * from "mytable"
and
SELECT * FROM "MYTABLE"
are different things, while
select * from mytable
and
SELECT * FROM MYTABLE
are the same.

Also
CREATE TABLE MYTABLE (...)
is the same as
create table mytable (...)
but which quoted select will be right?
Is the upper case or the lower case version "right"?
"MYTABLE" or "mytable"?
As far as I remember, this varies between vendors...


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se