Home » SQL & PL/SQL » SQL & PL/SQL » Help
Help [message #2052] Wed, 19 June 2002 05:58 Go to next message
Dhinakaran
Messages: 3
Registered: March 2002
Junior Member
Hai

I need a small help in writting the Oracle query.

I wrote the Oracle Query as below to retrieve the column name and Data type for the particular Username and table name

******************************************
SELECT COLUMN_NAME,DATA_TYPE FROM ALL_TAB_COLUMNS WHERE

OWNER='username' AND TABLE_NAME='tablename'

*******************************************************

I am getting the result properly if i have less than 25 columns.

But if i have more than 70 columns in my table, for the above query the column names were displayed randomely, not in the order.
I want to retrieve the column names in the Order.
Is there any alternate query to display the column names in the order if the tables has too many columns

Please help me

thanks

Dhinakaran
Re: Help [message #2059 is a reply to message #2052] Wed, 19 June 2002 08:59 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
order by column_id
Re: Help [message #2079 is a reply to message #2052] Thu, 20 June 2002 01:47 Go to previous message
Manu Gupta
Messages: 44
Registered: January 2002
Member
Dear Dhinakaran,

Whenever you pass the given query

SELECT COLUMN_NAME,DATA_TYPE FROM ALL_TAB_COLUMNS WHERE
OWNER='username' AND TABLE_NAME='tablename'

it will going to show records in order of COLUMN_NAME,
which is of varchar datatype resulting in appearing random COLUMN_ID
to you.

User ORDER BY COLUMN_ID clause in your select query to retrieve in order.

Manu
Previous Topic: query
Next Topic: min and max functions.
Goto Forum:
  


Current Time: Thu Apr 25 10:12:02 CDT 2024