如题!
测试如下:
SQL> create table test(id number,name varchar2(20));
Table created
SQL> insert into test values(1,'111');
1 row inserted
SQL> insert into test values(2,'111');
1 row inserted
SQL> insert into test values(3,'111');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> insert into test values(4,'222');
1 row inserted
SQL> commit;
Commit complete
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
4 222
3 111
1 111
2 111
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
2 111
3 111
4 222
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
2 111
3 111
4 222
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
4 222
3 111
1 111
2 111
SQL> alter system flush shared_pool;
System altered
SQL> commit;
Commit complete
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
4 222
3 111
1 111
2 111
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
2 111
3 111
4 222
SQL> delete from test where name='222';
1 row deleted
SQL> commit;
Commit complete
SQL> select * from test order by name;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL> select * from test order by name desc;
ID NAME
---------- --------------------
1 111
3 111
2 111
SQL>
问题:
1. 为什么正反序排序的结果一致?
2. 为什么加入第四条记录后,1,2,3的排序结果和只有前三条记录时的排序结果不同?
3. 删除第四条记录后,排序结果又和只有前三条记录时的排序结果一样了?
欢迎大家讨论