[DB-SIG] Quoting table and column names
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=
>'-'), 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.
select * from "mytable"
SELECT * FROM "MYTABLE"
are different things, while
select * from mytable
SELECT * FROM MYTABLE
are the same.
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...
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65