2007 May 25 9:00 PM
Hi,
Could any of you help me to know the following info?
I have a select statement as follows:
select * from ...into table int_tab where...
Once the select statement is executed, can I assume that the contents of int_tab is automatically sorted by the primary key of the table? Also please tell me how to prove it.
Please note that the select statement doesn't contain order by clause.
Thanks,
Thamarai
2007 May 25 9:38 PM
Since the SELECT statement supports the ORDER BY PRIMARY KEY clause, I don't think you can assume that it will be ordered by the primary key if you omit it.
Rob
Hi,
Could any of you help me to know the following info?
I have a select statement as follows:
select * from ...into table int_tab where...
Once the select statement is executed, can I assume that the contents of int_tab is automatically sorted by the primary key of the table? Also please tell me how to prove it.
Please note that the select statement doesn't contain order by clause.
Thanks,
Thamarai
2007 May 25 9:02 PM
Yes you can assume that.
Records are always fetched in the order, sorted by primary key.
The reason for this is an Index is created by default for the primary key and hence they are sorted.
If you are adding records in internal table after fetching data, then you can use SORTED TABLE.
There's no method to prove it but you can try fetching data from different tables by using different WHERE conditions.
I mean to say that just play with the select statement and it will be always sorted by primary key unless you specify ORDER BY clause.
2007 May 25 9:04 PM
By default it will take if you do not have any where condition and will not related to primary key..
if you keep where condition as per condition and then sorting will not work
i mean sorting will not take automatically and sorting is not related to primary key.
for better understanding please keep sort command after completion of sql query.
Reward Points if it is helpful
Thanks
Seshu
2007 May 25 9:38 PM
Since the SELECT statement supports the ORDER BY PRIMARY KEY clause, I don't think you can assume that it will be ordered by the primary key if you omit it.
Rob
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |