问题:
我是Oracle的新手,我想我错过了一些导致我的临时表空间填满的基本知识。
我打开与数据库的连接并多次运行pl / sql过程来插入行。每次运行该过程时,TEMP表空间中的空闲块数量都会减少。当空闲块的数量太少时,该过程将失败并出现错误" ORA-01652 - 无法在表空间"中将临时段扩展4096。如果我关闭数据库连接,TEMP表空间中的空闲块将重置为总块数,我可以继续重新运行该过程。如何在不关闭和打开数据库的情况下释放TEMP表空间块?我以为我需要添加一个提交声明,但这没有用。
由于
代码:
查询检查free_MB(每次运行程序时都会减少)。
SELECT tablespace_name,
total_blocks,
used_blocks,
free_blocks,
total_blocks*16/1024 as total_MB,
used_blocks*16/1024 as used_MB,
free_blocks*16/1024 as free_MB
FROM v$sort_segment;
SQL我多次运行,直到free_mb减少到0并且我得到错误:
DECLARE
p_samples LOG_ENTRY_ARRAY;
longSample clob;
BEGIN
For v_COUNTER IN 1..32767 LOOP
longSample := longSample || 'a';
END loop;
-- initialize the input
p_samples := LOG_ENTRY_ARRAY(longSample, 'short sample');
for i in 1..100 LOOP
INSERT_SUMMARY_SAMPLES('TABLE1', 1000, 1, 2, p_samples);
END loop;
commit;
END;
调用的过程将一堆插入到两个表中:
create or replace
PROCEDURE INSERT_SUMMARY_SAMPLES
(
p_TABLE_NAME IN VARCHAR2
, p_TS IN NUMBER
, p_SIGNATURE_ID IN NUMBER
, p_COUNT IN NUMBER
, p_SAMPLES IN LOG_ENTRY_ARRAY
) AS
tbl_summary varchar2(30);
tbl_samples varchar2(30);
summary_id number(10,0);
sample varchar2(32767);
BEGIN
tbl_summary := 'TBL_' || p_TABLE_NAME || '_SUMMARIES';
tbl_samples := 'TBL_' || p_TABLE_NAME || '_SAMPLES';
-- insert summary and get the id
EXECUTE IMMEDIATE 'INSERT INTO ' || tbl_summary
|| ' (agg_start_ts, signature_id, count, num_samples) VALUES (:a,:b,:c,:d) returning id into :1'
using p_ts, p_signature_id, p_count, p_SAMPLES.count returning into summary_id;
dbms_output.put_line('new summary_id is : ' || summary_id);
-- insert samples
FOR i in 1..p_SAMPLES.count LOOP
-- convert clob to varchar2
CLOB_TO_VARCHAR(p_SAMPLES(i),sample);
EXECUTE IMMEDIATE 'INSERT INTO ' || tbl_samples || ' (summary_id, log_entry) VALUES (:a,:b)' using summary_id, sample;
-- dbms_output.put_line('insert sample : ' || TO_CHAR(p_SAMPLES(i)));
END LOOP;
END INSERT_SUMMARY_SAMPLES;
CLOB_TO_VARCHAR是另一个程序:
create or replace
PROCEDURE CLOB_TO_VARCHAR (
p_clob IN CLOB,
p_varchar OUT VARCHAR2
)
AS
v_output varchar2(32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_clob_len INTEGER := 0;
BEGIN
l_clob_len := DBMS_LOB.getlength (p_clob);
WHILE l_pos < l_clob_len
LOOP
dbms_lob.READ(p_clob, l_amount, l_pos, v_output);
l_pos := l_pos + l_amount;
END LOOP;
p_varchar := v_output;
END CLOB_TO_VARCHAR;
答案 0 :(得分:0)
您的TEMP表空间快速填满。您可能需要手动增加表空间。 ORA-01652 Unable to extend temp segment by in tablespace和
可能重复ORA-01652: unable to extend temp segment by 128 in tablespace SYSTEM: How to extend?
答案 1 :(得分:0)
我猜你在某个地方有一个临时吊球,但它没有被明确释放。 LOG_ENTRY_ARRAY
定义在哪里?