2016-10-05 23 views
1

私は、Oracle SQLで新しいですし、私は次のコンテキストでテーブルの更新をしようとしています:表領域TEMPで128セグメントの一時セグメントを拡張できません。そのクエリを実行する別のオプションは?

+---------+---------+---------+----------+ 
| ColumnA | name | ColumnC | Column H | 
+---------+---------+---------+----------+ 
| 1  | Harry | null | null  | 
| 2  | Harry | null | null  | 
| 3  | Harry | null | null  | 
+---------+---------+---------+----------+ 

とテーブルB:

+---------+---------+---------+ 
| name | ColumnE | ColumnF | 
+---------+---------+---------+ 
| Harry | a  | d  | 
| Ron  | b  | e  | 
| Hermione| c  | f  | 
+---------+---------+---------+ 

私はテーブルAを持っています

そして、私は結果は次となるように、テーブルAを更新する:

+---------+---------+---------+----------+ 
| ColumnA | name | ColumnC | Column H | 
+---------+---------+---------+----------+ 
| 1  | Harry | a  | d  | 
| 2  | Harry | a  | d  | 
| 3  | Harry | a  | d  | 
+---------+---------+---------+----------+ 

Oracle SQL文に問題があります。

merge into tableA a 
using tableB b 
on (a.name=b.name) 
when matched then update set 
columnC = b.columnE, 
columnH = b.columnF 


create table tableA (columnC varchar2(20), columnH varchar2(20), name varchar2(20), columnA number); 
create table tableB (columnE varchar2(20), columnF varchar2(20), name varchar2(20)); 
insert into tableA values (null, null,'Harry',1); 
insert into tableA values (null, null,'Harry',3); 
insert into tableA values (null, null,'Harry',3); 
insert into tableB values ('a', 'd','Harry'); 
insert into tableB values ('b', 'e','Ron'); 
insert into tableB values ('c', 'f','Hermione'); 
select * from tableA; 
merge into tableA a 
using tableB b 
on (a.name=b.name) 
when matched then update set 
columnC = b.columnE, 
columnH = b.columnF; 
select * from tableA; 

問題は、私はそのコマンドを実行したときに、私は次のエラーを取得することです::

Error: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP

私はTEMP表領域に多くのスペースを与えることはできませんが、私は次のコンテキストを持っています。ですから、私の質問です:TEMPテーブルスペースを使用しない別のSQLクエリを使用するオプションはありますか?

+1

なぜ、TEMPテーブルスペースを増やせませんか?あなたはサーバーや何かのスペースを使い果たしてしまったのですが、それ以上物理的に追加することはできませんか?それともあなたのDBAや何かからのプッシュバックですか? IMOは、システムが12GBの一時表領域を消費するチューニング済の問合せを実行できる必要がある場合、少なくとも12GBの一時表領域を必要とするためです。一時的なテーブル・スペースを追加するように私のDBAに要求するのは苦労しない、一時的な特別な問合せに対してのみです。 – Boneist

答えて

2

あなたは多分それはあまりTEMP表領域を消費します次のクエリを試すことができます。

update tableA 
set (columnC, columnH) = (select ColumnE, ColumnF from tableB where tableB.name = tableA.name) 
where 
    tableA.name in (select tableB.name from tableB) 
; 

をそれとも、ループ内の小さなチャンクで更新を実行しようとすることができます。それほど性能が悪いですが、他の方法がなければ...

begin 
     FOR rec in 
     (select name, ColumnE, ColumnF from tableB) 
     LOOP 
     update tableA 
     set 
     columnC = rec.columnE 
     , columnH = rec.columnF 
     where name = rec.name 
     ; 
     end loop; 
    end; 
/
+0

私は1分後にそれを試し、結果をコメントします。早速のご返事ありがとうございます! – jartymcfly

+0

それはうまくいった!ありがとうございました! – jartymcfly

関連する問題