Jul 26, 2010 7:34 AM
Alias Name
-
Like (0)
Hi,
I need to have a column alias name with '+' & '[]'. Is that possible to do that.
Thanks in advance.
Thanks,
S.Sampath Kumar
What would be the business or computing requirement that such an alias would support? (I am curious) - but it may also generate discussion on the overarching problem you are trying to solve.
The short answer is that you can use any characters except " and \ in the column alias as long as you put the alias inside of double quotes:
select x as " ~#$%^&*()_=+-`{}[]|;:'/?>.,< " from foo;
I'm not sure why anyone would want to do so, but it is possible. Column names and aliases support all UTF8 characters except for the restriction of no " and \ characters. You might even be able to get " and \ to work as well, but I think it is disallowed because it would break other things if those characters got into the column names.
Hi David,
We have a report that generates the data in CSV format. In this we need the column names of this specific format. This report is generated through front end.
Thanks,
S.Sampath Kumar
Hi Shawn,
Your tip helped me in getting the solution. Thanks a lot.
Thanks,
S.Sampath Kumar
You can use the following syntax to achieve the mentioned column name:-
CREATE TABLE DEMO_NEW
( "NAME+ADDRESS" VARCHAR(100),
"[LOCATION]" VARCHAR(100)
);
But while referring the columns from the table, use the column name in double quotes as follows:
SELECT "NAME+ADDRESS", "[LOCATION]" FROM DEMO_NEW;
Thanks,
Litesh
Sampath,
The quoting of column names or aliases has more to do with inclusion of spaces within them. Say you need Employee Name as your column name. It is possible if we enclose them within double quotes:
CREATE TABLE EMP
(
"EMPLOYEE NAME" VARCHAR(10)
) DISTRIBUTE ON RANDOM;
:-) I have included the distribute clause only to make u all remember that if your table is not distributed properly then you are screwed up!
Thanks,
Nithin
Hi Lithesh & Nithin,
We have this to be done at the view level and I have got the results. Thanks for your suggestion.
Thanks,
S.Sampath Kumar

