How to Get Column Names of a Table in Oracle Query
You can select column names from table oracle database
** table name is upper **
select column_name from user_tab_cols where table_name =’PS_JOB’;
SELECT COLUMN_NAME FROM ALL_TAB_COLS WHERE TABLE_NAME =’PS_JOB’;
SELECT COLUMN_NAME FROM ALL_COL_COMMENTS WHERE TABLE_NAME = ‘PS_JOB’;
/* Sort Field by order in table*/
SELECT * FROM DBA_TAB_COLS WHERE TABLE_NAME =’PS_JOB’ ORDER by COLUMN_ID
SELECT COLUMN_NAME FROM DBA_TAB_COLS WHERE TABLE_NAME =’PS_JOB’ ORDER by COLUMN_ID
/* Sort Field by order in table and concate with ,*/
SELECT RTRIM (xmlagg (xmlelement (e, COLUMN_NAME || ‘,’)).extract (‘//text()’),’,’) COLUMN_NAMES FROM DBA_TAB_COLS WHERE TABLE_NAME =’PS_DEPT_TBL’ ORDER by COLUMN_ID
/* Select text all field form owner table */
SELECT ‘SELECT ‘||RTRIM (xmlagg (xmlelement (e, COLUMN_NAME || ‘,’)).extract (‘//text()’),’,’)||’ FROM ‘||OWNER||’.’||TABLE_NAME FROM ALL_TAB_COLS WHERE TABLE_NAME=’PS_DEPT_TBL’ GROUP BY OWNER,TABLE_NAME;