Oracle临时表 和 插入多条语句 用法

1、创建临时表  ON COMMIT PRESERVE ROWS 事务级别的,默认是回话级别的
DECLARE                                                 
                                   v_exists number;                                     
                                   BEGIN                                                   
                                      SELECT count(*) INTO v_exists    FROM   ALL_OBJECTS WHERE   OBJECT_NAME = 'TEMP1';  
                                      IF v_exists > 0 THEN  
                                        EXECUTE IMMEDIATE 'drop table TEMP1';  
                                      END IF;                                              
                                        EXECUTE IMMEDIATE'                                 
                                          CREATE GLOBAL TEMPORARY TABLE TEMP1  
                                            (                                              
                                                ITEMCODE VARCHAR(100),                     
                                                SQRQ     VARCHAR(100)                      
                                           ) ON COMMIT PRESERVE ROWS';                                             
                                   END ;  
2、插入多条数据
insert into tablename
select n1,n2 from dual union all
select n3,n4 from dual union all
select n5,n6 from dual     

                               
          
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cddchina/article/details/48498035
个人分类: Oracle
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭