1. select * into temptable from sourcetable;2. update a set a.num = (select num from b where a.no = b.no) // where a.no in (select no from b) 你自己看需要吗?3. select * from a where not exists(select * from b where a.no1=b.no1 and a.no2=b.no2):) 希望没错
1.cxgtommy提供的语法是什么版本的,我怎么试了不行,我也很想知道ORACLE里是否有临时表可用。 3.用外连接应该可以提高not in的效率: select * from a where a.no1 = b.no1(+) and a.no2 = b.no(2)(+) and b.no1 is null and b.no2 is null;//假如no1,no2都是主键,那么最后一个条件可不要。 另外,还可以用两个表的差集(我不记得了,好象是MINUS吧,查ORACLE的书看看),我没试过,不知道速度如何。
1. 写错了 create table temptable as select * from sourcetable
例2:存在A,B表, update a set a.num = (select b.num from b where a.no = b.no) from a
关于例1,解决办法如下: 1.使用FORMS_DDL函数创建临时表,如FORMS_DDL('create table tmp001 as select * from table1'); 2.使用临时表的数据; 3.在使用完临时表后,删除该表,如FORMS_DDL('Drop table tmp001');关于例2,解决办法如下: 1.先根据表a和表b建立视图,如FORMS_DDL('create view tmpview as select a.no,b.num,a.XXX... from a,b where a.no=b.no and b.no is not null'); 2.删除表a,再根据视图tmpview创建表a; 3.删除过渡性的视图;关于例3,解决办法如下: 使用外连接,如select a.no1,a.no2,a.XXX...from a,b where a.no1=b.no1(+) and a.no2=b.no2(+) and b.no1 is not null and b.no2 is not null;
:)给分吧!
1.select * into #tmp from table1 在ORACLE中应该这样: 如果选择出一条数据:SELECT Field1,Field2,... Into v_val1,v_val2,... from table; 如果选出多条数据则要用游标实现。 3.select a.no from table1 a,table2 b where a.no(+)=b.no
select *
into temptable
from sourcetable;2.
update a
set a.num = (select num from b where a.no = b.no)
// where a.no in (select no from b) 你自己看需要吗?3.
select *
from a
where not exists(select * from b where a.no1=b.no1 and a.no2=b.no2):)
希望没错
1、temptable是什么性质的表,是临时表吗?对它的操作会记录入日志吗?用完后,它会自动释放吗?
2、in 或 嵌套子查询的效率太低了吧?性能无法跟我在 SQL Server 中提的例子的性能相比。
3、性能也存在问题?
我不知道 oracle中只能这样写吗?有没有更好的办法?
3.用外连接应该可以提高not in的效率:
select * from a where a.no1 = b.no1(+) and a.no2 = b.no(2)(+) and b.no1 is null and b.no2 is null;//假如no1,no2都是主键,那么最后一个条件可不要。
另外,还可以用两个表的差集(我不记得了,好象是MINUS吧,查ORACLE的书看看),我没试过,不知道速度如何。
create table temptable
as
select *
from sourcetable
cxgtommy,你那个哪是临时表?
as
select *
from sourcetablesorry
startdate DATE,
enddate DATE,
cost NUMBER)
ON COMMIT PRESERVE ROWS;服务器会需要设置intiX.ora 中compatible=8.1.0
看样子,是8i的特性swordmanli 是报ora-406 compatible错吗?再次sorry
查阅命令:CREATE TEMPORARY TABLESPACE 及 CREATE TABLE
update a
set a.num = (select b.num from b where a.no = b.no)
from a
1.使用FORMS_DDL函数创建临时表,如FORMS_DDL('create table tmp001 as select * from table1');
2.使用临时表的数据;
3.在使用完临时表后,删除该表,如FORMS_DDL('Drop table tmp001');关于例2,解决办法如下:
1.先根据表a和表b建立视图,如FORMS_DDL('create view tmpview as select a.no,b.num,a.XXX... from a,b where a.no=b.no and b.no is not null');
2.删除表a,再根据视图tmpview创建表a;
3.删除过渡性的视图;关于例3,解决办法如下:
使用外连接,如select a.no1,a.no2,a.XXX...from a,b where a.no1=b.no1(+) and a.no2=b.no2(+) and b.no1 is not null and b.no2 is not null;
:)给分吧!
在ORACLE中应该这样:
如果选择出一条数据:SELECT Field1,Field2,... Into v_val1,v_val2,... from table;
如果选出多条数据则要用游标实现。
3.select a.no from table1 a,table2 b
where a.no(+)=b.no