GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 164 of 171    Print  
Select from table without using column name
How can I select column values from a table without knowing the column name ?
Suppose , select employee_id from employees , now I don't know the column name and I want to select the column.
Please let me know the answer



  
Total Answers and Comments: 13 Last Update: June 08, 2009     Asked by: sanjoy.dubey 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: checkout_rajesh
 
desc tablename; will show all column description
select * from tablename;

Above answer was rated as good by the following members:
atikullah123, upadesh_singh, Sowmya Viswanath
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
June 13, 2008 00:09:16   #1  
jiteshbiswas Member Since: June 2008   Contribution: 1    

RE: Select from table without using column name
select * from tableName
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
June 13, 2008 06:13:10   #2  
imran4108_4u Member Since: June 2008   Contribution: 3    

RE: Select from table without using column name
select * from tablename
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
June 16, 2008 02:25:07   #3  
checkout_rajesh Member Since: June 2008   Contribution: 1    

RE: Select from table without using column name
desc tablename; will show all column description
select * from tablename;

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
June 23, 2008 10:02:04   #4  
ramyaselvi16 Member Since: June 2008   Contribution: 15    

RE: Select from table without using column name
we must follow 2 steps.

1. to find out column name using table name.
2. Then we can take corresponding column name from above results.

Ex:
Select column_name from all_tab_columns where table_name 'countries';

The Output will be:
COLUMN_NAME
-------------------------
COUNTRY_ID
COUNTRY_NAME
REGION_ID


Then we wil use column names what u need from above list;

Ex:
select * from countries where country_id 91;


Rgds

Ramya

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
June 24, 2008 08:14:28   #5  
ramlalaGadai Member Since: February 2007   Contribution: 1    

RE: Select from table without using column name
I think we can also use the index of a column to select a cloumn without using the name.
 
Is this answer useful? Yes | No
June 24, 2008 12:04:41   #6  
srividhya_85 Member Since: June 2008   Contribution: 6    

RE: Select from table without using column name

To Know Column_Name from the table

Select COLUMN_NAME
from USER_TAB_COLUMNS
Where TABLE_NAME 'EMPLOYEES';


 
Is this answer useful? Yes | No
July 11, 2008 05:45:19   #7  
krishnaveni_g Member Since: July 2008   Contribution: 10    

RE: Select from table without using column name
You describe the table it will show all the columns in the table

Ex: Describe Employees;

 
Is this answer useful? Yes | No
August 27, 2008 03:18:41   #8  
navkmh Member Since: August 2008   Contribution: 1    

RE: Select from table without using column name
I have been using this sql query for selecting the column names of a table.
select column_name from information_schema.columns where table_name 'tablename'

Hope u find it useful.

-Naveen

 
Is this answer useful? Yes | No
September 01, 2008 04:41:48   #9  
raghuprasad Member Since: August 2007   Contribution: 23    

RE: Select from table without using column name
We can not select a particular column values without knowing it's name.

However we can select all the columns from a table using the following statement.

SELECT * FROM table_name;

 
Is this answer useful? Yes | No
March 07, 2009 00:35:31   #10  
ghoshamit83 Member Since: March 2009   Contribution: 1    

RE: Select from table without using column name
We can select from table without using column name.
We can select form table according to sequence of column but only sequentially we can do this thing.

For ex: Select 1 2 from table;
This query will give the result of those column which are in this sequence.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape