我已经为这个问题创建了一个简单的例子。以下查询为 order by 子句中不存在的所有列返回空值。如果我对 10g 运行查询,那就没问题了。这是前 n 个查询的基本实现。
我知道内部选择语句效率低下,但生成了 SQL(如果需要,我可以更改引擎)。
非常感谢所有帮助!
select * from (
select b.* from USER_table b
where b.id in (
select c.id from USER_table c where c.removed = 0
)
order by surname
) a where rownum <= 10
--------------------------------------------------------
-- DDL for Table USER_TABLE
--------------------------------------------------------
CREATE TABLE "CHRONICLE"."USER_TABLE"
( "FIRST_NAME" VARCHAR2(20 BYTE),
"SURNAME" VARCHAR2(20 BYTE),
"USERNAME" VARCHAR2(20 BYTE),
"REMOVED" NUMBER,
"ID" NUMBER
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- DDL for Index USER_TABLE_PK
--------------------------------------------------------
CREATE UNIQUE INDEX "CHRONICLE"."USER_TABLE_PK" ON "CHRONICLE"."USER_TABLE" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
--------------------------------------------------------
-- Constraints for Table USER_TABLE
--------------------------------------------------------
ALTER TABLE "CHRONICLE"."USER_TABLE" MODIFY ("ID" NOT NULL ENABLE);
ALTER TABLE "CHRONICLE"."USER_TABLE" ADD CONSTRAINT "USER_TABLE_PK" PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ENABLE;
oracle 版本是 10.2.0.1。
它在 Windows 2008 R2 x64 上运行
解释 11g 的计划
解释 10g 的计划