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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cddchina/article/details/48498035
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     

                               
          
阅读更多 登录后自动展开
想对作者说点什么? 我来说一句

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