Two Laptop Bag*
The moose likes Oracle/OAS and the fly likes select vs desc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "select vs desc" Watch "select vs desc" New topic
Author

select vs desc

Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
hi guys

i want to know when execuite a query like "desc TableName"
it will return a column name and the column datatype in the order they where
in the table even though you execuite different times you will get same order

but if we execuite a query like "select * from TableName"
it will return resultset of different order at different times

in both the query we are not using any order by statement
i want to know what makes desc statement resultset consistenet

regards
amir
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Amirtharaj Chinnaraj:
hi guys

i want to know when execuite a query like "desc TableName"
it will return a column name and the column datatype in the order they where
in the table even though you execuite different times you will get same order

but if we execuite a query like "select * from TableName"
it will return resultset of different order at different times

in both the query we are not using any order by statement
i want to know what makes desc statement resultset consistenet

regards
amir


You are confusing the describe a table (DESC TableName) statement with the descending key word used in an order by clause. You will get the same result if you execute DESCRIBE TableName as you do with Desc TableName. Its purpose is to give you information about your table's make-up... it isn't intended to provide a result set.
[ October 24, 2007: Message edited by: Paul Campbell ]
Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 236
well paul

let me expalin my doubt clearly ,iam using mysql database i use jdbc to
connect with database

when i execute a select query without order by statement i get different ordered resultset at different times

but when i execute a describe query i get the resultset with the same order for n number times what makes desc to be consistent

if i want to oder the resultset of a describe query how can i do it for mysql

regards
amir
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
You can't order the information returned from a describe table statement.
The statement/command is for providing information about the columns of the table. It shows the column names, the type / size and scale (if applicable) and other useful information.

DESCRIBE table_name

However, you can do describe output select * from table_name ordered by...
[ October 25, 2007: Message edited by: Paul Campbell ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select vs desc
 
Similar Threads
Result Set Sorting
How to retrieve the first record in a database table
Passing Database query results through a method to a JTable
MySQL driver problem?
ResultSet.getXXX() arg - Favour column-name or column-index?