how to get column names from the table [message #632930] |
Sat, 07 February 2015 13:10 |
|
orcle_us
Messages: 21 Registered: February 2015
|
Junior Member |
|
|
I need to query the database to get the column names, not to be confused with data in the table. For example, if I have a table named st_records that contains student_id,name, english, maths then I would want to retrieve say column english (without data)from the query
Can you help me please?
Many thanks
|
|
|
|
|
|
|
|
|
Re: how to get column names from the table [message #632941 is a reply to message #632940] |
Sat, 07 February 2015 16:14 |
|
orcle_us
Messages: 21 Registered: February 2015
|
Junior Member |
|
|
you are a great help for a beginner like me. Thank you both .
when i type in
SQL> desc st_records;
Name Null? Type
----------------------------------------- -------- ----------------------------
SN NUMBER(3)
ST_ID CHAR(40)
NAME VARCHAR2(20)
ENGLISH NUMBER(3)
MATHS NUMBER(3)
SQL> select column_name from user_tab_columns where table_name = 'st_records' an
d column_id in (3);
no rows selected
SQL> select english from st_records;
ENGLISH
----------
78
67
75
92
56
SQL> select column_name from user_tab_columns where table_name = 'st_records' an
d column_id in (3,4);
no rows selected
[Updated on: Sat, 07 February 2015 16:23] Report message to a moderator
|
|
|
|
|
|
|