Skip navigation
14885 Views 7 Replies Latest reply: Aug 12, 2010 5:25 AM by Sampath RSS
Sampath New Enzee 9 posts since
Oct 28, 2009
Currently Being Moderated

Jul 26, 2010 7:34 AM

Alias Name

Hi,

 

I need to have a column alias name with '+' & '[]'. Is that possible to do that.

 

Thanks in advance.

 

Thanks,

S.Sampath Kumar

  • David Birmingham Active Enzee 426 posts since
    Sep 24, 2007
    Currently Being Moderated
    1. Jul 26, 2010 8:58 AM (in response to Sampath)
    Re: Alias Name

    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.

  • Shawn Fox Enzee Exraordinaire 1,333 posts since
    Aug 15, 2006
    Currently Being Moderated
    2. Jul 26, 2010 12:50 PM (in response to Sampath)
    Re: Alias Name

    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.

  • litesh New Enzee 2 posts since
    Jul 27, 2010
    Currently Being Moderated
    5. Aug 2, 2010 2:43 AM (in response to Sampath)
    Re: Alias Name

    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

  • Nithin Subhakar New Enzee 22 posts since
    May 9, 2007
    Currently Being Moderated
    6. Aug 5, 2010 4:25 PM (in response to litesh)
    Re: Alias Name

    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

More Like This

  • Retrieving data ...

Bookmarked By (0)