How to use symbols in SQL column names?

Bitterblue picture Bitterblue · Oct 29, 2014 · Viewed 8.8k times · Source

I tried to use column names with symbols like minus, dot and a few others. Oracle SQL parser doesn't except them. Like this:

select
    a.ID as Article-Number, a.Name as Name
from
    Articles a
where
    (a.ID = '3264')

And it doesn't except a.ID as 'Article-Number' (says "FROM keyword not found where expected"). Can I have symbols in column names?

Answer

Mureinik picture Mureinik · Oct 29, 2014

You can use double quotes (") to escape aliases and column names:

select
    a.ID as "Article-Number", a.Name as "Name"
from
    Articles a
where
    (a.ID = '3264')