Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
I have to find the 3rd column of a table Person. i dont know the column name.



thank you in advance
Posted
Comments
Nandakishore G N 9-Feb-12 10:09am    
can.You explain little.more?
chinta123 9-Feb-12 10:50am    
hi,I have a table name called person and there is 3 columns FirstName,LastName,Age ,I dont know the column name,but i only know there are 3 columns ,i have to extract the 3 rd column name and also the data .
Sergey Alexandrovich Kryukov 9-Feb-12 14:08pm    
This is not how SQL and relationship databases work.
--SA

If you select all the data, and move to the third colum in the construct that contains it, then you can find the data in the third column.

This[^] is apparently how you find column names. Note: I don't use Oracle, I just know how to google.
 
Share this answer
 
Comments
chinta123 9-Feb-12 10:51am    
Can u please tell me briefly,so that i can understand and please give an example.
Jörgen Andersson 9-Feb-12 16:16pm    
The link Christian gave you is correct. Run: SELECT column_name,data_type,data_length,data_precision,nullable FROM all_tab_cols where table_name ='My_Table';
The third row in the resultset is the data for the third column in your table.
Christian Graus 9-Feb-12 10:52am    
As I said, I don't use Oracle, I just know how to use Google. That page, I found with google, explains how to find out the columns in a table. That's what you want to do, isn't it ?
As I say, this is not how SQL and relationship data bases work. You need to know a column. However, you can learn what columns are there in your table.

For example, look at this answer:
http://forums.sureshkumar.net/oracle-sql-server-sybase-others/22736-sql-query-find-column-names-table.html[^].

The idea is getting meta-data from the Oracle system table, in this example, all_tab_cols.

See also:
http://en.wikipedia.org/wiki/Metadata[^],
http://en.wikipedia.org/wiki/Database_schema[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900