Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

database table sorting

Former Member
0 Likes
847

hi everyone:

I want to sort the database talbe record.in native sql statements,what statement I

can use.can sort statement work?

thanks a lot

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
832

Please check SELECT with ORDER BY option

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a53358411d1829f0000e829fbfe/content.htm

a®s

Edited by: a®s on Jan 26, 2008 12:01 AM

Read only

0 Likes
832

I only want to sort the database record,not fetch data,no matter how ,I will try your idea,thanks

Read only

0 Likes
832

database sort is done by system by primary key , if you want to sort the database records other than primary key then you need to use for secondary index.

a®

Read only

0 Likes
832

hi

I have created a secondary index,but the result is the same as the old version,

I think native sql will be helpful,but i donot know what should i do? my background

datasystem is oracle

Read only

Read only

Former Member
0 Likes
832

Hi,

why want you do that? By design the order of records in a table doesn't matter.

If you want to make use of the records you have to SELECT them.

When you SELECT them you can have an ORDER BY, voila it's sorted.

Let's say you inserted a bunch of rows ORDERED into the table. Well it's fine...

You do a SELECT * from table

The question is: will you get the rows ordered? The answer: yes, no, maybe

You have to SELECT and ORDER BY to be sure to have the table ordered.

I.E. databases are storing rows in a storage-efficient way (ORACLE uses so-called blocks for that).

When you SELECT it visits all blocks that contain the rows and give them back in a efficient (not ordererd ) way back. The database uses a Cost based optimizer (CBO) to do that.

The result set can than be ordered by the query plan given by the CBO.

Hoe that helps