Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL SELECT problem
You cannot do it directly (this how a relational database works), but you may be able to do it in a roundabout way, as follows:
SPOOL myfile.sql
SELECT 'SELECT '||column_name||' FROM '||table_name||';'
FROM user_tab_columns
WHERE table_name='your_table_name'
AND column_id=2;
SPOOL OFF Then run the SQL file you just created: @myfile[.sql].
If you are the owner/creator of the table, this should do it; otherwise, you may have to use the DBA_TAB_COLUMNS or ALL_TAB_COLUMNS tables and stick the OWNER column both in the SELECT and the WHERE clause.
I hope this helps.
Michael Serbanescu
Sr. Consultant, MIACO Corporation
Received on Sun Apr 27 1997 - 00:00:00 CDT