Take the 2-minute tour ×

I have a table TABLE_A on Oracle and it has multiple columns beginning with X. For ex. Xxaa, xxyyy, aax etc. Now I want to select fields, which begin with X. Is there any way using wildcards?

share|improve this question

3 Answers 3

You can build the query via dynamic SQL and then run it as you see fit:

  SQL_QUERY   varchar2(4000);
  select    'select '
         || LISTAGG(CNAME, ',') within group (order by CNAME)
         || ' from table_a'
    into SQL_QUERY
    from COL
   where TNAME = 'TABLE_A' and CNAME like 'X%';

share|improve this answer
Thanks Mr. John. This is what I want. –  user1622391 Aug 24 '12 at 13:07

No, you cannot do that. You need to list each column "manually".

(Btw: this sounds like a very strange requirement and it might indicate a poor design - but this is hard to tell with the information you have given).

share|improve this answer

Sort of, but you'd have to use them in the meta tables (syscolumns thingies), and then build a query and then execute it. Be easier to do a better design, than something as fragile as that.

share|improve this answer

Your Answer


