日期:2014-05-17  浏览次数:20712 次

这种语法在sqlserver2000中不报错,谁试一下在oracle中是不是会报错呀.
--测试
create   table   a
(
a1   int,
a2   int
)

create   table   b
(
b1   int,
b2   int
)

insert   into   a   select   1,11
insert   into   a   select   2,12

insert   into   b   select   1,31
insert   into   b   select   3,32

--这样写竟然没有错误提示!!!
select   *   from   a
where   a1   not   in   (select   a1   from   b)

--这样写竟然没有错误提示!!!

select   *   from   #a
where   a1   =   (select   top   1   a1   from   #b)

为什么呢?

------解决方案--------------------
没有top
------解决方案--------------------
insert into a select 1,11
改成 insert into a select 1,11 from dual

select * from #a
where a1 = (select top 1 a1 from #b)
改成
select * from #a
where a1 = (select a1 from #b where rownum = 1)
------解决方案--------------------
没有#表,没有top
------解决方案--------------------
肯定报错.
------解决方案--------------------
ztoracle中临时表

1) ON COMMIT DELETE ROWS 定义了建立事务级临时表的方法.
CREATE GLOBAL TEMPORARY TABLE admin_work_area
(startdate DATE,
enddate DATE,
class CHAR(20))
ON COMMIT DELETE ROWS;

2)ON COMMIT PRESERVE ROWS 定义了创建会话级临时表的方法.
CREATE GLOBAL TEMPORARY TABLE admin_work_area
(startdate DATE,
enddate DATE,
class CHAR(20))
ON COMMIT PRESERVE ROWS;