特性说明
在Oracle模式下,OceanBase临时表已经实现了基本的create、select、insert、delete、update等功能。为了满足更多客户的需求,OceanBase正在扩展临时表的功能,例如支持merge into和insert all操作。merge into允许用户将源表中的数据行以更新或插入的方式合并到目标表中,而insert all则允许用户一次性将数据插入到多个目标表中。
在OceanBase 4.2.2 版本中,OceanBase对merge into、insert all临时表的功能进行了支持,同时还支持了insert、update、delete包含临时表的视图。下文详细介绍这三种使用场景。
使用场景
merge into临时表
临时表可作为merge into的目标表、源表,若merge into的目标表、源表是视图,视图中也可包含临时表。
下面对功能进行举例说明。
首先创建临时表temp1和非临时表t1。
create global temporary table temp1(c1 int,c2 int) on commit preserve rows;
create table t1(c1 int, c2 int);
然后向temp1和t1中插入一些数据。
insert into temp1 values(1,1),(2,2),(5,5);
insert into t1 values(1,2),(2,4),(3,6);
使用t1作为源表,temp1作为目标表,做merge into操作,将t1表中的数据和temp1表中的数据进