可以使用视图吗!视图IN ORACLE IS THE SAME WITH SQL SERVER

解决方案 »

  1.   

    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):)
    希望没错
      

  2.   

    请问
    1、temptable是什么性质的表,是临时表吗?对它的操作会记录入日志吗?用完后,它会自动释放吗?
    2、in 或 嵌套子查询的效率太低了吧?性能无法跟我在 SQL Server 中提的例子的性能相比。
    3、性能也存在问题?
    我不知道 oracle中只能这样写吗?有没有更好的办法?
      

  3.   

    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的书看看),我没试过,不知道速度如何。
      

  4.   

    1. 写错了
      create table temptable
      as
      select *
      from sourcetable
      

  5.   

    我也写错了,b.no(2)没有括号。
    cxgtommy,你那个哪是临时表?
      

  6.   

    swordmanli要的临时表是不是退出后会自动drop的?2。不用子查询的话实在不知道怎么做。 3。peng_hui回答了。minus是差集,对于可以用outer join的地方应该不需要minus了或union。另外问句,sql3有谁熟悉?包含sql server那些sql语法吗?
      

  7.   

    我所指的临时表是退出后会自动drop的,而且对它的操作不记录日志的,而且是针对特定连接建立的,多个连接会产生多个临时表的那种!
      

  8.   

    1.create temporary table temptable
      as
      select *
      from sourcetablesorry
      

  9.   

    兄弟,你的这种写法我在 Function 中试过了,好象不成功,你这语法自己试过吗?
      

  10.   

    CREATE GLOBAL TEMPORARY TABLE flight_schedule (
       startdate DATE, 
       enddate DATE, 
       cost NUMBER)
       ON COMMIT PRESERVE ROWS;服务器会需要设置intiX.ora 中compatible=8.1.0
    看样子,是8i的特性swordmanli 是报ora-406 compatible错吗?再次sorry
      

  11.   

    Oracle 8i里支持临时表,Oracle 7不支持。
    查阅命令:CREATE TEMPORARY TABLESPACE 及 CREATE TABLE
      

  12.   

    例2:存在A,B表,
    update a
      set a.num = (select b.num from b where a.no = b.no)
      from a 
      

  13.   

    关于例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;
     
    :)给分吧!
      

  14.   

    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