Link to home
Start Free TrialLog in
Avatar of toooki
toooki

asked on

Oracle table insert new row question

I created an oracle (11gR2) table TAB1
with this command:
CREATE TABLE LCTB_REPORT_SRVC
   (      ID NUMBER,
      F1 VARCHAR2(20)
   );

Now I insert into this table:
(1, 'myval1')
(2, 'myval2')
...
...
and so on

Later if type select * from TAB1
The o/p does not show with id value ascending.

Is there any way that the select * from TAB1  will always show the o/p in id values ascending?
Avatar of enachemc
enachemc
Flag of Afghanistan image

select * from TAB1 order by id
hi
- your table is TAB1 or LCTB_REPORT_SRVC?

select * from TAB1 order by id ASC
OR
select * from LCTB_REPORT_SRVC order by id ASC
- 'ASC' is ascending order
Avatar of toooki
toooki

ASKER

Thank you all for your replies.

My table is MYTAB1. Sorry.

I know select * from TAB1 order by id will give the O/P I want to see.

I inserted the values in order (I mean first inserted the row with id =1, then id=2 ...).

I was thinking if there was any way for it to show in correct id ascending order without the "order by id" clause in the select statement.
- can you further explain on the "correct id ascending order?" is it based on the sequence when you insert the data?
Avatar of toooki

ASKER

No. I did not use sequence.
Just inserted the number values for ID column. As it is anyway a small table.

By correct order means .. just it looks awkward if select * and see the IDs not in order (when I inserted in order).
I know tables don't store records in order.

Otherwise, well maybe then there is no other way...
SOLUTION
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
according to u ur table is TAB1   and u  create table name of    CREATE TABLE LCTB_REPORT_SRVC
.... than u


 fetech a data from TAB1....
 thst is ur ist mistake ....


and ur 2 mistake is  U create a table table name TAB1 thst is reserve word in oracle 11g....
Since when did TAB1 become a reserved word?
- i'm wondering the same too.
- BTW toooki already corrected that his table name is MYTAB1 if you read the whole posting here :)
Avatar of toooki

ASKER

Thank you all.
I see some post there http://tkyte.blogspot.com/2005/08/order-in-court.html as slightwv mentioned.
Well it is not a huge issue for me. I asked just to see if there was an easy way for it.
Thanks!