[DB-SIG] Quoting table and column names
Wed, 19 Jun 2002 14:19:48 -0700
On Wednesday 19 June 2002 14:18, Ryan Weisenberger wrote:
> Is it safe to ALWAYS quote table names and column names in SQL
> statements? My python app queries against several different kinds of
> databases, most notably Oracle 8 and 9, MS SQL Server 2000, and
> Sybase. When table and column names contain spaces or characters (':' =
> '-'), I surround them with double quotes. So is it safe to always do
> this? I thought at one time I discovered that some dbs don't like this=
This is DBSS specific.
For example, Postgresql requires you to use single quotes when you want t=
generate a string literal, and double quotes when you need to quote an en=
name (column, table, etc) that has spaces in it.
However, MySQL decide to not follow SQL standards, and lets you use singl=
double quotes to specify string literals, and you need to use backticks t=
quote an entity name (Can you see my anti-MySQL bias, here? :)
So, if you're quite willing to reject MySQL as a valid target for your=20
application "because it doesn't follow standards", then the answer is yes=
("`-/")_.-'"``-._ Chris Cogdon <firstname.lastname@example.org>
. . `; -._ )-;-,_`)
(v_,)' _ )`-.\ ``-'
_.- _..-_/ / ((.'
((,.-' ((,/ fL